博客
关于我
Objective-C实现BMP图像旋转180度(附完整源码)
阅读量:794 次
发布时间:2023-02-17

本文共 1836 字,大约阅读时间需要 6 分钟。

Objective-C??BMP????180?

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?????????????

  • ????File Header??????????????reserved?unused?format???bits per pixel?width?height????
  • ????Information Header????????????????planes????
  • ?????Pixel Data????????????
  • ???BMP?????????????????????????????????????????????

    ????????BMP????????????????????????

    ?????????

    ?????????????????

  • ???????????????????????????????????
  • ??????????????????????????
  • ???????????????????????????
  • ??????????????????

  • ?????????ARC?????????
  • ????????????????????
  • ??????????????????
  • ????????????????BMP????????????????????????

    ??????????????????????????????????????

    转载地址:http://fcnfk.baihongyu.com/

    你可能感兴趣的文章
    NSSet集合 无序的 不能重复的
    查看>>
    NSURLSession下载和断点续传
    查看>>
    NSUserdefault读书笔记
    查看>>
    NS图绘制工具推荐
    查看>>
    NT AUTHORITY\NETWORK SERVICE 权限问题
    查看>>
    NT symbols are incorrect, please fix symbols
    查看>>
    ntelliJ IDEA 报错:找不到包或者找不到符号
    查看>>
    NTFS文件权限管理实战
    查看>>
    ntko web firefox跨浏览器插件_深度比较:2019年6个最好的跨浏览器测试工具
    查看>>
    ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
    查看>>
    ntp server 用法小结
    查看>>
    ntpdate 通过外网同步时间
    查看>>
    NTPD使用/etc/ntp.conf配置时钟同步详解
    查看>>
    NTP及Chrony时间同步服务设置
    查看>>
    NTP配置
    查看>>
    NUC1077 Humble Numbers【数学计算+打表】
    查看>>
    NuGet Gallery 开源项目快速入门指南
    查看>>
    NuGet(微软.NET开发平台的软件包管理工具)在VisualStudio中的安装的使用
    查看>>
    nuget.org 无法加载源 https://api.nuget.org/v3/index.json 的服务索引
    查看>>
    Nuget~管理自己的包包
    查看>>