Manipulating RAW pixels from UIImage
2 posters
Manipulating RAW pixels from UIImage
Can anyone here help me get the raw (as in bitmap data array) from an UIImage (in my case returned from imagepicker)
I'm seen several apps that do image processing so i know it's possible. The posts/articles that google has given me have been filled with things like "well I think it's like in OSX and you can do X" but haven't seen any code that seems to work for me.
Thanks a million in advance
I'm seen several apps that do image processing so i know it's possible. The posts/articles that google has given me have been filled with things like "well I think it's like in OSX and you can do X" but haven't seen any code that seems to work for me.
Thanks a million in advance
afastrunner- Posts : 4
Join date : 2009-01-25
Re: Manipulating RAW pixels from UIImage
- Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
SIO2image *_SIO2image = NULL;
CGImageRef img;
CGContextRef ctx;
// Create a new image
_SIO2image = sio2ImageInit( "image/wall.tga" );
img = image.CGImage;
// Take the image selected inside the image picker controller
// and create a texture from it.
if( img )
{
HAVEPIC = 1;
_SIO2image->width = CGImageGetWidth( img );
_SIO2image->height = CGImageGetHeight( img );
_SIO2image->bits = 4;
_SIO2image->tex = ( unsigned char *) malloc( _SIO2image->width *
_SIO2image->height *
_SIO2image->bits );
ctx = CGBitmapContextCreate( _SIO2image->tex,
_SIO2image->width,
_SIO2image->height,
8,
_SIO2image->width * _SIO2image->bits,
CGImageGetColorSpace( img ),
kCGImageAlphaPremultipliedLast );
CGContextDrawImage( ctx,
CGRectMake( 0.0, 0.0,
(CGFloat)_SIO2image->width,
(CGFloat)_SIO2image->height ), img );
CGContextRelease( ctx );
// Scale the image to the nearest power of 2
sio2ImageScale( _SIO2image,
sio2GetNextPow2( _SIO2image->width ),
sio2GetNextPow2( _SIO2image->height ) );
// Convert RGBA to BGRA since SIO2 only support
// BGRA for 32bits texture.
sio2ImageRGBAtoBGRA( _SIO2image );
// Generate the texture ID
sio2ImageGenId( _SIO2image, SIO2_IMAGE_CLAMP, 0.0f );
}
// Hide our image picker.
imagePickerController.view.hidden = YES;
}
Re: Manipulating RAW pixels from UIImage
At what point though would I be able to modify the pixels to change to greyscale or perform an edge detect filter etc?
afastrunner- Posts : 4
Join date : 2009-01-25
Re: Manipulating RAW pixels from UIImage
Before sio2ImageGenId, all the pixels are ordered properly in _SIO2image->tex (BGRA), or if you want to work with RGBA before sio2ImageRGBAtoBGRA
Permissions in this forum:
You cannot reply to topics in this forum