返回顶部

收藏

将图像数据转换成多种图像格式

更多
//ESSImageCategory header preview

#import 

@interface NSImage (ESSImageCategory)
- (NSData *)JPEGRepresentation;
- (NSData *)JPEG2000Representation;
- (NSData *)PNGRepresentation;
- (NSData *)GIFRepresentation;
- (NSData *)BMPRepresentation;
@end

//===================================
//ESSImageCategory source preview

//
//  ESSImageCategory.m
//
//  Created by Matthias Gansrigler on 1/24/07.
//  Copyright 2007 Eternal Storms Software. All rights reserved.
//

#import "ESSImageCategory.h"

@implementation NSImage (ESSImageCategory)

- (NSData* )representationForFileType: (NSBitmapImageFileType) fileType 
{
  NSData *temp = [self TIFFRepresentation];
  NSBitmapImageRep *bitmap = [NSBitmapImageRep imageRepWithData:temp];
  NSData *imgData = [bitmap representationUsingType:fileType properties:nil];
  return imgData;
}

- (NSData *)JPEGRepresentation
{
   return [self representationForFileType: NSJPEGFileType];
}

- (NSData *)PNGRepresentation
{
  return [self representationForFileType: NSPNGFileType];
}

- (NSData *)JPEG2000Representation
{
  return [self representationForFileType: NSJPEG2000FileType];  
}

- (NSData *)GIFRepresentation
{
  return [self representationForFileType: NSGIFFileType];  
}

- (NSData *)BMPRepresentation
{
  return [self representationForFileType: NSBMPFileType];    
}

@end
//该片段来自于http://outofmemory.cn

标签:objective-c,图形

收藏

0人收藏

支持

0

反对

0

发表评论