SORU
14 HAZİRAN 2010, PAZARTESİ


Nasıl yeni bir dosya olarak kaydetmek için NSİmage

Nasıl yeni bir dosya olarak bir NSİmage kaydedebilirsiniz (png, jpg ...) belirli bir dizinde mi?

Cevap benim "" soru. noobish için teşekkür ederim

CEVAP
9 Temmuz 2010, Cuma


Bu gibi NSİmage için bir kategori ekleyebilirsiniz

@interface NSImage(saveAsJpegWithName)
- (void) saveAsJpegWithName:(NSString*) fileName;
@end

@implementation NSImage(saveAsJpegWithName)

- (void) saveAsJpegWithName:(NSString*) fileName
{
    // Cache the reduced image
    NSData *imageData = [self TIFFRepresentation];
    NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];
    NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0] forKey:NSImageCompressionFactor];
    imageData = [imageRep representationUsingType:NSJPEGFileType properties:imageProps];
    [imageData writeToFile:fileName atomically:NO];        
}

@end

"Önemli aksi takdirde olabilir" geçerli bir görüntü elde değil. TİFFRepresentation için çağrı

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • beautyexchange

    beautyexchan

    4 EYLÜL 2006
  • buttheadgsxr1000

    buttheadgsxr

    24 Ocak 2008
  • tinycammonitor

    tinycammonit

    14 Aralık 2010