本文共 1836 字,大约阅读时间需要 6 分钟。
BMP??????
BMP??????????????????????????????????????????????
????
????????Objective-C?????BMP???????180??
#import@interface BMPHelper : NSObject+ (UIImage *)rotateBMP:(NSData *)bmpData;@end
#import "BMPHelper.h"@implementation BMPHelper+ (UIImage *)rotateBMP:(NSData *)bmpData { // 1. ??BMP?? NSBitmapImageData *bitmapData = [NSBitmapImageData dataWithData:bmpData]; // 2. ??????BMP???? void *bitmapBuffer = malloc(bitmapData.bytesPerRow * bitmapData.height); // 3. ??????BMP?? NSImage *rotatedImage = [[NSImage alloc] initWithData:bitmapData]; // 4. ?????? for (int y = 0; y < bitmapData.height; y++) { for (int x = 0; x < bitmapData.width; x++) { // ??180???????(x, y)??(x, height - y - 1) // ???????????? // ??????????BMP??????? } } free(bitmapBuffer); return [rotatedImage rotatedImage];}@end ?????????????BMP????????????????????BMP?????????????????
????????
?????????????????BMP??????????rotateBMP????????????????????
NSData *bmpData = [NSData dataWithContentsOfFile:@"yourBMPFile.bmp"];UIImage *rotatedImage = [BMPHelper rotateBMP:bmpData];[rotatedImage setImage:UIImageView * imageView];
??????????????BMP??????????BMPHelper????????????????????UI????
BMP?????????
BMP?????????????
???BMP?????????????????????????????????????????????
????????BMP????????????????????????
?????????
?????????????????
??????????????????
????????????????BMP????????????????????????
??????????????????????????????????????
转载地址:http://fcnfk.baihongyu.com/