Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Create CGImage from an array of bytes (pixels)

$
0
0

Hey,

I'm fairly new to iOS and Xamarin. I dove into image editing and immediately hit a brick wall. I'm using CGBitmapContext to feed image information into a byte[] array. After that, I'm manipulating that array to create a custom image, or so is the plan. Now I'm wondering how to turn these bytes back into a CGImage. I've tried the CGImage constructor, but that didn't seem to work. The image appears to just be white. My code looks roughly something like that:

//data is the byte[] array containing pixel information
CGDataProvider provider = new CGDataProvider(data);
CGImage image = new CGImage(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, CGBitmapFlags.PremultipliedLast, provider, null, true, CGColorRenderingIntent.Default);

Is this even the right approach? Does the constructor expect different parameters or should this work and I'm doing something wrong elsewhere? Any help is appreciated!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>