title: How to create an image with black and white pixels?
body: <p>I'm trying to create a black and white image that on the one hand can be displayed in an <code>UIImageView</code> and on the other hand it should be possible to share this image via e-mail or just be saved to camera roll. </p>
  
  <p>I've got a two dimensional array (<code>NSArray</code> containing other <code>NSArrays</code>) which contains a matrix with the <code>NSInteger</code> values <strong>0 and 1</strong> (for a white and a black pixel). </p>
  
  <p>So I just want to place a black pixel for a 1 and a white one for a 0.
  All other questions I found deal with changing pixels from an existing image.
  I hope you can help me!</p>
  
  <p>[EDIT]:</p>
  
  <p>Of course, I didn't want someone to do my work. I couldn't figure out how to create a new image and place the pixels as I wanted to at first, so I tried to edit an existing image that only consists of white pixels and change the color of the pixel if necessary. So my code for trying this, but as you can see I had no idea how the change the pixel. I hope that shows that i was trying on my own.</p>
  
  <pre><code>- (UIImage*) createQRCodeWithText:(NSString*) text andErrorCorrectionLevel:(NSInteger) level {
      QRGenerator *qr = [[QRGenerator alloc] init];
      NSArray *matrix = [qr createQRCodeMatrixWithText:text andCorrectionLevel:level];
  
      UIImage *image_base = [UIImage imageNamed:@"qr_base.png"];
      CGImageRef imageRef = image_base.CGImage;
  
      for (int row = 0; row &lt; [matrix count]; row++) {
          for (int column = 0; column &lt; [matrix count]; column++) {
              if ([[[matrix objectAtIndex:row] objectAtIndex:column] integerValue] == 1) {
                  //set pixel (column, row) black
              }
          }
      }
  
      return [[UIImage alloc] initWithCGImage:imageRef];
  }
  </code></pre>