Solved

Save a JPEG returned from EZTWAIN

Posted on 2004-03-22
2
956 Views
Last Modified: 2012-06-21
Trying to save a scanned image as a JPEG file. I acquire the image using EZ TWAIN dll and get back a handle to a DIB. How do I take this handle to the DIB and save it to a JPEG file using the sample code:

http://www.vbaccelerator.com/codelib/gfx/vbjpeg.htm

I been trying to use the SAVEJPG method of the cDIBSECTION class but can't seem to figure out how to convert the handle to a DIB to a cDIBSECTION object so that I can pass that to the SAVEJPG method.

Also looked at FreeImage:
http://freeimage.sourceforge.net/download.html
All example in C++, couldn't figure them out. Need VB code examples

0
Comment
Question by:cshorey
2 Comments
 
LVL 10

Accepted Solution

by:
Kavar earned 500 total points
ID: 10648825

best I can tell you will need to create a suitable DC, then draw to it, I believe (dont have the structures in front of me)
that the cDIBSection has a DC property, so you should just be able to copy the contents of the db you have a handle to
and then save it.
Declare Function TWAIN_CreateDibPalette Lib "EZTW32.DLL" Alias "TWAIN_CreateDibPalette" _
      ( ByVal hdib as Long ) as Long
'
'  Create and return a logical palette to be used for drawing the DIB.
'  For 1, 4, and 8-bit DIBs the palette contains the DIB color table.
'  For 24-bit DIBs, a default halftone palette is returned.
'
Declare Sub TWAIN_DrawDibToDC Lib "EZTW32.DLL" Alias "TWAIN_DrawDibToDC" _
      ( ByVal hDC as Long, ByVal dx as Long, ByVal dy as Long, _
        ByVal w as Long, ByVal h as Long, ByVal hdib as Long, _
        ByVal sx as Long, ByVal sy as Long )
'
'  Draws a DIB on a device context.
'  You should call CreateDibPalette, select that palette
'  into the DC, and do a RealizePalette(hDC) first.



0
 

Expert Comment

by:spike0xFF
ID: 10818703
The 'Pro' version of EZTwain (http://www.dosadi.com/eztwain3.htm) is commercial, but can load & save JPEG files (and TIFF, PNG, etc.) - It uses the IJG's LibJpeg which is freely available.

[Disclaimer: I'm the author of EZTwain and EZTwain Pro.]
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question