Loading...

GetPixelByteArray

Discussions about image processing in GdPicture.NET using GdPictureImaging.

GetPixelByteArray

Postby BenV » Thu Jan 27, 2011 11:08 am

Could it be that the returned byte array is not properly formatted? I get an ArgumentException in the following code:

Code: Select all
...
ReDim pixels(SquareHeight * tsImageWidth * 4)
pictureImaging.GetPixelArrayByte(timesheetImage, pixels, 0, topLeftYCor + ((rowNr - 1) * SquareHeight), tsImageWidth, SquareHeight)
Dim taskByte() As Byte = pixels
Dim taskMS As New MemoryStream(taskByte)
Dim taskImage As Image = Image.FromStream(taskMS)          <==        ArgumentException
Dim task As New Bitmap(taskImage)

Whereas when I use an existing image, convert it to a byte array and pass it to the FromStream method, it works like a charm.
BenV
 
Posts: 20
Joined: Thu Dec 02, 2010 4:54 pm

Re: GetPixelByteArray

Postby Loïc » Thu Jan 27, 2011 6:59 pm

Hi,

The following line:
Image.FromStream(taskMS)

Is expecting that taskMS contains an image document in binary format. Not from pixel data.

You should replace GetPixelByteArray by SaveAsByteArray method.

Let me know if you need some clarifications.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: GetPixelByteArray

Postby BenV » Tue Feb 08, 2011 11:11 am

Sorry for the late reply but I was on vacation. I edited the code and it works. Thanks for the help, Loic.
BenV
 
Posts: 20
Joined: Thu Dec 02, 2010 4:54 pm


Return to Image Processing

Who is online

Users browsing this forum: No registered users and 0 guests

cron