画像をある形式 (.png) から別の画像形式 (.img 形式) に変換したいと考えています。同じ画像フォーマットの rgba 値を取得して変更することができました。他の画像フォーマットに変換するために他に何か必要なことはありますか?
空のビットマップを作成し、このビットマップをイメージするために描画したいと考えています。
CGImageRef cgimage = image.CGImage;
size_t width = CGImageGetWidth(cgimage);
size_t height = CGImageGetHeight(cgimage);
size_t bytesPerRow = CGImageGetBytesPerRow(cgimage);
size_t bytesPerPixel = CGImageGetBitsPerPixel(cgimage);
size_t bitsPerComponent = CGImageGetBitsPerComponent(cgimage);
size_t bytes_per_pixel = bytesPerPixel / bitsPerComponent;
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(cgimage);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
unsigned char *rawData = malloc(height * width * 4);
memset(rawData, 0, height * width * 4);
CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), image.CGImage);
iOS には、出力ビットマップを変更された rgba 値で埋める機能がありますか。