Solved

Save a JPEG returned from EZTWAIN

Posted on 2004-03-22
2
954 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 63
Fibonacci challenge 11 109
topping3 challenge 14 69
groovy example issue 10 89
This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now