Solved

Save a JPEG returned from EZTWAIN

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
This article will show, step by step, how to integrate R code into a R Sweave document
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 …
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…

744 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

14 Experts available now in Live!

Get 1:1 Help Now