Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i handling UIImage using a pointer?
    primarykey
    data
    text
    <p>i'm studying iOS programming.</p> <p>i have to handling an image.</p> <p>i must make an image to BMP file. but iOS doesn't support to make BMP file.</p> <p>so i think that maybe i use a pointer i can make BMP file.</p> <p>i make a header for BMP. and put it in an <code>NSData</code> object.</p> <p>now i left saving image data's to that <code>NSData</code>.(i'll say bmpData)</p> <p>here's start my wondering.</p> <p>i have to have image which size is 128 x 64.</p> <p>i get the <code>UIImage</code> from a context. (i'll say image1)</p> <p>and i make a <code>CGSize</code> which is 128 x 64.</p> <p>i make a context2 using that size, drawing an image1</p> <p>now i get the <code>UIImage</code> from a context2, which size is 128 x 64, resized image1.</p> <p>and i make an <code>UIImageView</code> and use image2, it works fine. good. image2 is made well.</p> <p>so i declared a pointer, which is unsigned char *.</p> <pre><code>unsigned char *bmpDataPointer = (unsigned char *)image2; </code></pre> <p>and i use for loop</p> <pre><code>for(int i = 0; i &lt; 64; ++i) { for(int j = 0 ; j &lt; 128; ++j) { // dataObj and bmpData are different NSData object // dataObj just contain bitmap data to check my pointer works fine or not. [dataObj appendBytes:&amp;(bitmapDataPointer[i*1 + j]) length:sizeof(char)]; } } </code></pre> <p>and i make a <code>UIImage</code> to check that data is valid, it fails.</p> <pre><code>UIImage *createdImageUsedByaPointer = [UIImage imageWithData:dataObj]; if(createdImageUsedByaPointer == nil) { NSLog(@"nil!"); } </code></pre> <p>ok run. then string nil will be presented.</p> <p>why is that? i make context size 128 x 64, so i loop 128 x 64 times.</p> <p>but it works bad.</p> <p>how can i fix that??</p> <p>how can i handling an <code>UIImage</code> to use a pointer??</p> <p>anybody knows about that please help me.</p>
    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.
 

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