I made a scrolling tile 2D video game in visual basic a few years back. I am translating it to Cocoa for the Mac. Is there a framework that would allow me to use BitBlt? Or is there an equivalent to BitBlt without using OpenGL? Thanks!
BitBlt() equivalent in Objective-C/Cocoa
2.5k Views Asked by Brian At
2
There are 2 best solutions below
0

As Matt mentioned, you probably want CGContextDrawImage
and CGContextSetBlendMode
.
First, you need to create a CGImageRef
from the image data. You do this with a data provider. If you already have the image loaded in memory, then you should use CGDataProviderCreateDirect
. That data provider will be a parameter to CGImageCreate
.
Next, in your Cocoa view's drawRect:
method, you'll want to get the current context like this:
CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
Then use CGContextDrawImage
to draw the image.
As Matt mentioned, you can control blending with CGContextSetBlendMode
.
You should probably start with Core Graphics