Je travaille sur une application qui permet à un utilisateur de prendre une photo de son appareil photo ou de prendre une photo. De l'image, je dois augmenter la taille à 1050x670 et garder la qualité de l'image. Je suis capable d'augmenter l'image, mais l'image sort très pixélisée quand je l'envoie par email.iPhone - Agrandir l'image, garder la qualité
Dans l'application, je vais envoyer l'image agrandie à un serveur pour un traitement supplémentaire.
Toute aide serait appréciée. Voici une partie du code:
CGSize newSize = CGSizeMake(1050, 670);
CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width, newSize.height));
CGImageRef imageRef = [userImageView.image CGImage];
// Compute the bytes per row of the new image
size_t bytesPerRow = CGImageGetBitsPerPixel(imageRef)/CGImageGetBitsPerComponent(imageRef) * newRect.size.width;
bytesPerRow = 26 * 1050;//(bytesPerRow + 15) & ~15;
CGContextRef bitmap = CGBitmapContextCreate(NULL,
newRect.size.width,
newRect.size.height,
8,
bytesPerRow,
CGImageGetColorSpace(imageRef),
kCGImageAlphaNoneSkipLast);
CGContextSetInterpolationQuality(bitmap, kCGInterpolationHigh);
// Draw into the context; this scales the image
CGContextDrawImage(bitmap, newRect, imageRef);
// Get the resized image from the context and a UIImage
CGImageRef resizedImageRef = CGBitmapContextCreateImage(bitmap);
UIImage *resizedImage = [UIImage imageWithCGImage:resizedImageRef];
// Clean up
CGContextRelease(bitmap);
CGImageRelease(resizedImageRef);
UIImageWriteToSavedPhotosAlbum(resizedImage, nil, nil, nil);
return resizedImage;
Qu'est-ce que vous attendez-vous? Le zoom d'une image n'ajoute aucun détail à l'image, donc il devient flou ou pixélisé ... – Lucero
Vous ne pouvez pas ajouter de pixels supplémentaires (ou de détails) à une image qui n'était pas là pour commencer –
Pourquoi pas vous? Je peux le faire via Photoshop sans pixelliser l'image. Est-ce que je manque quelque chose? –