views:

22

answers:

1

I'm trying to draw an image using OpenGL in a project for iPad.

The image data: A data blob of UInt8 that represents the grayscale value for each pixel in three dimensions (I'm going to draw slices from the 3D-body). I also have information on height and width for the image.

My current (unsuccessful) approach is to use it as a texture on a square and I am looking at some example code I found on the net. That code, however, loads an image file from the disc.

While setting up the view there is a call to CGContextDrawImage and the last parameter is suposed to be an CGImageRef. Do you know how I can create one from my data or is this a dead end?

Thankful for all input. I really haven't gotten the grip of OpenGL yet so please be gentle :-)

A: 

It's not a dead end.

You can create an CGImageRef from a blob of pixel memory using CGBitmapContextCreate() to create a bitmap context and CGBitmapContextCreateImage() to create the image ref from the bitmap context.

hotpaw2