Converting a UIImage to a ByteArray in Monotouch

Monotouch Tips Part 1

Today I'm doing a post on a common problem I see a lot of people run into whilst developing with Monotouch. Having the ability to consume web services within Monotouch is a great feature of Monotouch however - normally sending data files over web services happens using byte arrays. To send data as a byte array, you will need to do the following:

UIImage To ByteArray example

Obviously, this example is UIImage specific since this is what I've used in the past and gives a better example on what's needed to convert a real object to a byte array.

I'm hopefully getting a blog post up soon on how to achieve the "Loading..." screen look and feel as well as creating a custom cell in code. 

Hope this helps,

ChrisNTR

Published Tuesday, November 03, 2009 8:59 PM by Chris Hardy (ChrisNTR)
Filed under: , , , ,

Comments

# MonoTouch Article - Tip - Converting a UIImage to a ByteArray

Tuesday, November 03, 2009 5:52 PM by MonoTouch.Info

Thank you for submitting this entry - Trackback from MonoTouch.Info

# re: Converting a UIImage to a ByteArray in Monotouch

Tuesday, November 03, 2009 6:00 PM by Alan

For the cases where you don't want to create a large managed buffer and copy all the data over, you could use UnmanagedMemoryStream to wrap the UIIMage.Data pointer. Then you have a regular stream to pass around.

The only caveat is that you have to be careful that the stream is disposed *before* the UIImage is disposed.

# Converting a UIImage to a ByteArray in Monotouch | I love .NET!

Pingback from  Converting a UIImage to a ByteArray in Monotouch | I love .NET!

# Twitter Trackbacks for Converting a UIImage to a ByteArray in Monotouch - Chris Hardy [asp.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 Converting a UIImage to a ByteArray in Monotouch - Chris Hardy         [asp.net]        on Topsy.com

# re: Converting a UIImage to a ByteArray in Monotouch

Wednesday, November 11, 2009 5:13 PM by Aaron

Hi Chris,

Another great tip.  Would really appreciate if you could find the time to blog on the loading screen!  Yours looks quite good and I am having trouble getting mine to work at all.

Cheers

# re: Converting a UIImage to a ByteArray in Monotouch

Thursday, November 12, 2009 5:22 PM by Chris Hardy (ChrisNTR)

@Aaron - Hey,

Yeah, I'm getting the post ready to go, just been pretty busy the last week. Hopefully I can get something up on Saturday.

Cheers,

ChrisNTR

Leave a Comment

(required) 
(required) 
(optional)
(required)