Reputation: 261
I want to save into the Photo Album (I guess), a large black & white image which I need to create via code like a bitmap. The App will produce simple paths that need to be printed out to use as templates, no colour is needed, and because some might be very large, black & white is fine (no need for grayscale). I could do with any ideas as a good starting point. i.e. specify size, add a black pixel to an x,y, save out to .png? thanks for any pointers..
Upvotes: 0
Views: 576
Reputation: 299265
There are two questions here: how to create a bitmap that you can manipulate pixels in, and how to print simple black and white paths. Those are really different things, so let's look at both.
For drawing on a simple bitmap, you use a CGBitmapContext
. See Creating a Bitmap Graphics Context for details on creating them. In the process of generating it, you'll need to provide the memory layout, and you can then modify the bits in that memory space to draw. When you're done, you'll create an image using CGBitmapContextCreateImage
. Here's an example on SO: Convert bitmap image information into CGImage in iPhone OS 3
That said, I don't think this is really what you want to do. If you want to print, then you should use the printing API. See Drawing and Printing Guide for iOS.
If what you really mean is that you want to save files that can be printed elsewhere, then what you want is PDF, not bitmap. For that, also see the Drawing and Printing Guide for iOS, Generating PDF Content. You can then draw things using Quartz or UIKit into the PDF context and pull a PDF out to be saved or printed. For a black and white line drawing, this is likely much more efficient and smaller than a bitmap.
Upvotes: 1