Solved

Save a JPEG returned from EZTWAIN

Posted on 2004-03-22
2
961 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
troubleshoot a python script 8 110
Java array 10 85
Java List 4 73
Java Inheritance super keyword use 8 68
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

738 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