0
我想將圖像從一種格式(.png)轉換爲其他圖像格式(.img格式)。我能夠檢索和修改相同圖像格式的rgba值。是否有任何額外的事情我需要做的將其轉換爲其他圖像格式?如何在iOS中創建和檢索新的位圖
我創建了一個空位圖,並想繪製圖像這個位圖。
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值。
你是什麼意思「如何在iOS中將數據繪製到位圖」?你是否正在討論在特定點採用像素選取顏色? –
@TBlue:修改標題 – Ram
我讀得越多,我越感到困惑。您指定的擴展名之一(.img)直到十年前才被用作光盤映像格式。 –