zoukankan      html  css  js  c++  java
  • ios 从rgb array生成UIImage并显示,oc版

        const size_t Width = 1080;
        const size_t Height = 1080;
        const size_t Area = Width * Height;
        const size_t channles = 4; // rgba
        std::vector<uint8_t> output(Area*channles);
        uint8_t *outputdata = output.data();
     
         
        // create the bitmap context:
        const size_t BitsPerComponent = 8;
        const size_t BytesPerRow=((BitsPerComponent * Width) / 8) * channles;
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef gtx = CGBitmapContextCreate(outputdata, Width, Height, BitsPerComponent, BytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
        
        // create the image:
        CGImageRef toCGImage = CGBitmapContextCreateImage(gtx);
        UIImage *image = [[UIImage alloc] initWithCGImage:toCGImage];
        
        [self.imageView setImage:image];
  • 相关阅读:
    configparser模块
    xml文件解析
    shutil模块 + shelve模块 二合一版
    hashlib模块
    subprocess模块和sys模块
    re模块
    os模块
    random模块
    time模块、datetime模块讲解
    洛谷P3414 SAC#1
  • 原文地址:https://www.cnblogs.com/mlj318/p/6486053.html
Copyright © 2011-2022 走看看