[MonoTouch] Building a UIImage from a byte[]

Nic Wise nicw at fastchicken.co.nz
Wed Mar 28 08:11:37 UTC 2012


What format is the data in?

I think LoadFromData expects a PNG, JPG or similar.

>From the docs:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html

"returns a new image object for the specified data, or nil if the
method could not initialize the image from the specified data."

Formats:

Table 1  Supported file formats
Format
Filename extensions
Tagged Image File Format (TIFF)
.tiff, .tif
Joint Photographic Experts Group (JPEG)
.jpg, .jpeg
Graphic Interchange Format (GIF)
.gif
Portable Network Graphic (PNG)
.png
Windows Bitmap Format (DIB)
.bmp, .BMPf
Windows Icon Format
.ico
Windows Cursor
.cur
XWindow bitmap
.xbm

You might be able to load a CGImage with ARGB values, then make a
UIImage from that...





On Tue, Mar 27, 2012 at 20:53, UC Scr1pter <ucscr1pter at gmail.com> wrote:
> Hi,
>
> I'm trying to build a UIImage from a byte array containing ARGB data.  My
> code is as follows:
>
> private UIImage ImageFromBytes(byte[] ImageBuffer)
> {
>        NSData ImgData = NSData.FromArray(ImgBuffer);
>        return UIImage.LoadFromData(ImgData);
> }
>
> This always returns null for me.  Can someone point out where I'm going
> wrong.
>
>
>
>
> --
> Best regards,
>  UC                          mailto:ucscr1pter at gmail.com
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2


More information about the MonoTouch mailing list