Good day!

I am working on pixel based drawing tool, and could use some hint on how to handle selection areas.

In the program, each document has a couple different Bitmap context (24 bit RGP space CGBitmapContext ) at the same time. I draw into a scroll view using a Layer (CGLayer). Whenever one of the bitmap context changes, I copy the changes into the layer, but scrolling within the view is done only with the layer except for drawing the selection area.

As always, I want to make sure there isn't a better way of doing what I am doing now.

To handle the selection, I have been using a CGBitmapContext (created with method CGBitmapContextCreate with a bitsPerComponent of 8, a color space of GreySpace, and CGBitmap info of kCGImageAlphaNone). This gives me an editable context, so that I can create the selection graphic using Quartz draw rectangles and ovals. When I need to draw using the selection, I convert the selection into an image (CGBitmapContextCreateImage), clip the context to that image (CGContextClipToMask) and then do whatever drawing I want to do (ex. invert, special fill, you name it).

First of all, it is possible to create a single bit bitmap context (only black and white)? I could only get 8 bit greyscale working correctly.

Should I be using ImageMask for these operations? I did not create a bitmap mask (using CGImageMaskCreate) because I needed to be able to constantly modify the mask using rectangle and oval commands (and I could not get that call to work).

Lastly, when when drawing between bitmap context (basically copying one section to another), is the best way to create an Image from the bitmap info (CGBitmapContextCreateImage) and then draw using the image. Apple documentation suggest that this is quick enough. If I create an image, and then modify the context, the image I created would have a copy of the data, not any changes.

Thanks for any comments!

Steve Sheets
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to