Troubleshooting GetScanLines

Discussions about image processing and document imaging.
Post Reply
MrH
Posts: 14
Joined: Mon Feb 16, 2015 11:15 am

Troubleshooting GetScanLines

Post by MrH » Fri May 22, 2015 1:18 pm

Programming language: C#
GdPicture Version: 11.1.14

I try to get the bytes from a Picture so I tried to use GetScanLines.

Code: Select all

var scanlines = gdPictureImaging.GetScanLines(ImageId);
var scanLineWidth = gdPictureImaging.GetStride(ImageId);

foreach (var t in scanlines)
                {
                    var idata = new byte[scanLineWidth];   
                    Marshal.Copy(t, idata, 0, scanLineWidth);
                    //Do something with the idata-Array
                }
So that is my code, but everything I get is a byte array filled with "\0" for each entry. Am I doing something wrong?

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Troubleshooting GetScanLines

Post by Loïc » Sat May 23, 2015 1:22 pm

Hi,

I don't see anything wrong. Here the adjusted snippet I used to test from my end:

Code: Select all

            using (GdPicture11.GdPictureImaging gdPictureImaging = new GdPictureImaging())
            {
                int ImageId = gdPictureImaging.CreateGdPictureImageFromFile(@"d:\test.png");
                IntPtr[] scanlines = gdPictureImaging.GetScanLines(ImageId);
                int scanLineWidth = Math.Abs(gdPictureImaging.GetStride(ImageId));
                foreach (IntPtr line in scanlines)
                {
                    byte[] data = new byte[scanLineWidth];
                    Marshal.Copy(line, data, 0, scanLineWidth);
                    //Do something with the idata-Array
                }
            }

If the problem persists with my code please share the input image you are using.

With best regards,

Loïc

MrH
Posts: 14
Joined: Mon Feb 16, 2015 11:15 am

Re: Troubleshooting GetScanLines

Post by MrH » Mon Jun 15, 2015 3:42 pm

okay after a while I found the problem and it wasn't my code at all.

The Problem is in GdPicture Version 9 the bytes are all fine but in the Version 11, I use right now, I had to invert all bytes with "~" befor I can hand over them to the OCR Engine.

I have to say the project that works with your lib in Version 9 we use the COM-DLL but the Version 11 is used with C# and WPF.

I haven't tried what will happen if I use the the COM-DLL in Version 11. Maybe there works everything fine.

Kind regards
MrH

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests