Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/instm/UIImage/initWithData%3a" rel="nofollow">see the supported image formats for UIImage in table 1 here</a></p> <p>.tiff .tif .jpg .jpeg .gif .png .bmp .ico .cur .xbm are all readily incorporated using native methods of UIImage.</p> <p>If it is at all possible to get your images into this format before your app ingests them, you should try to do this as the <code>imageWithContentsOfFile:</code> or the <code>imageWithData:</code> methods will be infinitely less work for you to do than writing and using custom classes to parse and convert another format. </p> <p>Do you have a specific format you HAVE to use which can't be converted to a .tif .jpg .bmp or .png first?</p> <p><strong>Updating in response to OP</strong></p> <p>There may be projects out there that have done similar, but the only related experience I can offer you comes from a machine vision project where I had processed raw pixel data into raw data, and loaded it back into a CGImageRef for consumption by the interface.</p> <p>You'll likely be directly allocating memory and working in straight C for some of it</p> <p>Here's a taste of what I did (and again, no guarantees this will apply to your situation):</p> <pre><code>size_t bitMatrixSize = (height-2*k_kernelPixelRadius) * (width-2*k_kernelPixelRadius); unsigned char *bitMatrix = malloc(bitMatrixSize); //back to int, so only 1 byte per pixel needed //other methods manipulated the data stored in this unsigned char, then passed it to the following method +(CGImageRef)newImageFromBitMatrix:(unsigned char*)bitMatrix originalImagePixelHeight:(int)origHeight originalImagePixelWidth:(int)origWidth{ int pixelsInBitMatrix = (origHeight - (2 * k_kernelPixelRadius)) * (origWidth - (2 * k_kernelPixelRadius)); unsigned char *rawData = malloc(pixelsInBitMatrix * 4); //1 byte per char, 4 bytes per pixel (RGBA) int outputColor = 0; int byteIndex = 0; for (int i = 0; i &lt; pixelsInBitMatrix; i++) { //outputColor = (bitMatrix[i] == 1) ? 255 : 0; //This is the shorter form, the undefined grey was included for debugging. Remove it later if (bitMatrix[i] == 1) { outputColor = 255; } else if (bitMatrix[i] == 0) { outputColor = 0; } else { outputColor = 150; } rawData[byteIndex] = outputColor; rawData[byteIndex + 1] = outputColor; rawData[byteIndex + 2] = outputColor; rawData[byteIndex + 3] = 255; //alpha channel byteIndex += 4; } CGContextRef ctx = NULL; CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB(); size_t contextWidth = origWidth - (2 * k_kernelPixelRadius); size_t contextHeight = origHeight - (2 * k_kernelPixelRadius); size_t bytesPerRow = 4 * contextWidth; ctx = CGBitmapContextCreate(rawData, contextWidth, contextHeight, 8, bytesPerRow, deviceRGB, kCGImageAlphaPremultipliedLast ); CGImageRef thresholdImage = CGBitmapContextCreateImage (ctx); CGColorSpaceRelease(deviceRGB); CGContextRelease(ctx); free(rawData); return thresholdImage; free(bitMatrix); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload