I'm using GdPicture to acquire images from a scanning device. 90% of these images will be monochrome but I seem to be having trouble when converting these monochrome images to other image format datatypes (such as AtalaImage or System.Drawing.Bitmap).
If I scan an image in monochrome and then examine the stride setting using the GetStride() property, the property returns '-320' as a value (negative values for the stride should be impossible). When I attempt to convert this image to other formats (in this particular instance an AtalaImage using the Atalasoft.Image.FromBitmap() method), I get an error from the Atalasoft image framework saying that an 'Unusual or invalid row stride property has been detected'. As the bitmap conversion fails at this point, the program can't display the converted bitmap image.
However if I scan the image as 24-bit colour, 256 color, or grayscale and then use the ChangePixelFormat() method to convert the image to 'Format1bppIndexed', GetStride() returns a value of '320' (notice the stride value is now positive and not negative), and the image datatype conversions take place without any problems.
Could you confirm whether or not this is a bug in GdPicture as I only seem to get the problem when handling GdPicture image objects.
Thanks in advance.
A negative stride means that this image pixel source is bottom right and not top left.
Its not a bug. A scanner returns image as dib with pixel source as bottom right therefore, the GetStride methods returns a negative value.
Maybe you should use the CreateClonedGdPictureImageI to create a new bitmap having a positive stride and pixel source from top-left side.
Code: Select all
Dim ClonedImage as Integer = oGdPictureImaging.CreateClonedGdPictureImageI(SrcImage)
Hope this helps.
That seems to have done the trick, and the image objects are now converting successfully. Many thanks.
We are having to use a bit of an odd configuration at the moment, as we progress to becoming 100% GdPicture. We currently acquire images using Atalasoft TWAIN, back-end process and manipulate them using GdPicture, and then pass them to an Atalasoft Viewer for display.
Atalasoft TWAIN [AtalaImage Object] >>>> GdPictureImaging [GdPictureImage Object] >>>> Atalasoft Viewer [AtalaImage Object]
The problem we had was at the location of the red arrow, because the viewer MUST have an AtalaImage object as opposed to a standard bitmap object.
I'm still unsure as to why this only affects monochrome images though! Images scanned at 24-bit, 8-bit and 4-bit greyscale all seem to work OK, even without the modification you suggested. Is there some difference in the way these are returned, or is it more likely to be something in the way that Atalasoft TWAIN returns the acquired image when dealing with monochrome? We'll probably be moving to GdTWAIN soon so it doesn't really matter, but it's a lot of manpower to make the move which is why we're current working as we are with 2 separate components.
I'll probably raise this on their forums too because it seems like inconsistent behaviour to me.
Once again many thanks.
I have the same problem as above but I'm using GdPicture12 so the CreateClonedGdPictureImageI method is no longer available. I've tried using the CreateClonedGdPictureImage method instead but the image stride is still negative on the cloned image.
When using GdPicture12, is there a way to clone the image and create a new bitmap with a positive stride?
Who is online
Users browsing this forum: Bing [Bot] and 1 guest