Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One problem I see right off the bat is you are using the raster cell number for both your X and Y origin. A raster in this configuration is just a single dimension line. It is up to you to calculate the second dimension based on the raster image's width. That could explain why you got a line.</p> <p>Another thing: seems like you are reading every pixel of the image. Didn't you want to skip pixels that are the width of the the ellipses you are trying to draw?</p> <p>Next thing that looks suspicious is I think you should create the context you are drawing in <em>before</em> drawing. In addition, you should not be calling:</p> <pre><code>CGContextRef contextRef = UIGraphicsGetCurrentContext(); CGContextSaveGState(contextRef); </code></pre> <p>and</p> <pre><code>CGContextRestoreGState(contextRef); </code></pre> <p>inside the loop.</p> <p>EDIT:</p> <p>One further observation: your read RGB values are 0-255, and the <code>CGContextSetRGBFillColor</code> function expects values to be between 0.f - 1.f. This would explain why you got white. So you need to divide by 255:</p> <pre><code>CGContextSetRGBFillColor(contextRef, red / 255, green / 255, blue / 255, 1.0); </code></pre> <p>If you have any further questions, please don't hesitate to ask!</p> <p>EDIT 2:</p> <p>To calculate the row, first declare a row counter outside the loop:</p> <pre><code>int row = 0; //declare before the loop int imageWidth = self.size.width; //get the image width if ((i % imageWidth) == 0) { //we divide the cell number and if the remainder is 0 //then we want to increment the row counter row++; } </code></pre> <p>We can also use mod to calculate the current column:</p> <pre><code>int col = i % imageWidth; //divide i by the image width. the remainder is the col num </code></pre> <p>EDIT 3: You have to put this inside the for loop:</p> <pre><code>if ((row%imageWidth)==0) { row++; } int col = row%imageWidth; </code></pre> <p>Also, I forgot to mention before, to make the column and row 0 based (which is what you want) you will need to subtract 1 from the image size:</p> <pre><code> int imageWidth = self.size.width - 1; </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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