Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use scanner as copier

Posted on 2000-05-17
16
Medium Priority
?
518 Views
Last Modified: 2010-04-04
I am trying to write an application that will use a scanner/printer as a photocopier.

I have a component that does the scanning and puts the result in a TImage.

How can I then print it so that it looks like the original?
0
Comment
Question by:sharons
[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
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 2820213
Are you scanning the entire page? It should just be a case of outputting the image to the printer a la:

Printer.BeginDoc;
Printer.Canvas.StretchDraw(RECT(0, 0, Printer.PageWidth, Printer.PageHeight), Image1.Picture.Bitmap);
Printer.EndDoc;

The Neil =:)
0
 

Author Comment

by:sharons
ID: 2820267
Thank you Neil. Now it fills the page but for some reason the quality is very poor, like it's been fax and photocopied many times.

I tried an application from the Internet that allows you to make copies like I describe and the quality was perfect. Therefore I know this is possible.  Maybe the problem as to do with how I load the picture.The Twain component I am using is MCM Twain.
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2820310
I don't know the component that you're using but to get decent quality out of it you're going to have to scan at something like 200dpi (at least). That's going to mean a lot of memory. There are a few things to try first though:

Are you in 16/24 bit colour mode?
Is the graphic being stored in a visual component? (Faster if you can store it purely in memory)
Is the scanner setup correctly?
If you're only using a B&W printer, try scanning as greyscale instead of true colour

How big is the scanned image (in terms of pixels)? I think you'll find that this is the root of your problem (or I hope so as we can easily fix it)

The Neil =:)
0
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!

 
LVL 2

Expert Comment

by:mullet_attack
ID: 2820458
I agree with TheNeil. Scan the image into a memory DC at the highest res you can afford, I'd use 300 DPI as that's common amongst laser and inkjet's. At 300 dpi scanned, your image on screen is huge (probably 72 dpi, so it's approx 16 times bigger !), hence the need for the memory DC. Once scanned, you can Bitblt the MemDC onto an image to show the user.
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2820479
The DPI is probably the root of low quality but just in case it isn't, what version of Delphi are you using Sharons? Delphi 2's implementation of StretchDraw is useless for the Printer and you have to start using StretchBlt

The Neil =:)

PS Thanks Mullet_Attack - does help to know that I'm not coming up with stupid ideas on my own (well, not all the time anyway)
0
 

Expert Comment

by:Portal
ID: 2820802
Actually the most probable reason the printer comes out low quality is that you should be using stretchdibs instead of stretchdraw.

To prove that the image can be printed better try printing it with Microsoft Word - it should come out a lot better.

Also check out this link at comparison printouts between stretchdraw and stretchdibs.

http://www.efg2.com/lab/OtherProjects/PrinterDemo1.htm
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2820817
Portal,

This used to be a problem but Borland went and fixed it for later versions of Delphi (4 and 5 certainly, but don't know about 3). Version 2 was a nightmare and Stretchdraw DID look awful

The Neil =:)
0
 
LVL 2

Accepted Solution

by:
mullet_attack earned 900 total points
ID: 2821548
Let's stop for a second. An A4 page is  about 8 1/2 inches by 11 inches. At even 200 dpi that's 1700 x 2200 pixels. I doubt that sharons's TImage is that big. At half a high res screen it's gonna be at most about 500 wide by 750 high. That's less than one ninth the resolution. If you stretch the Timage to fit the A4 page, it's gonna look like rubbish no matter what streching routine you use. The only solution is to scan at a reasonable res into memory, and print from that memory. That A4 page at 24 bit color is nearly 4 meg. No wonder scan and print is a slow process.

Try scanning at decent res into Timage, and have Stretch true. The Timage will have the high res pic in memory, but display a shrunk, low-res version.

Portal : Word does this this. It 'stores' images internally and only shows a shrunk version in the document. Proves this by changing the zoom % in word. You can go from unreadable rubbish to perfect image and back again.

BTW you might use GetDeviceCaps to get the printer resolution, and determine your scan resolution from there, to try and match them up.

0
 

Author Comment

by:sharons
ID: 2821552
I am using Delphi 5.

Do you have an example of using StretchDIBits to take the content of a TImage and print it.
0
 

Author Comment

by:sharons
ID: 2821562
Tha scanned image is an 8 1/2 by 11 page with some text.
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2821588
In Delphi 5 it won't make any difference. I haven't used StretchDIBits for several years (which is how much faith I have in StretchDraw). Trust me, StretchDraw works perfectly in Delphi 5

The Neil =:)
0
 

Author Comment

by:sharons
ID: 2822497
I think it might be more of a scanner issue than a delphi issue. It seems that the result of the scanning produces a large bitmap, much larger than the page. When it is reduced to fit a page, I think that's when the poor quality is created.

I am just trying to figure out why the bitmap cannot simply be the right size.
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2824662
What do you mean 'bigger than the page'? If the bitmap is bigger than the page, the StretchDraw routine will simply shrink it to fit (or raise the dpi depending on how you look at it). In fact, the bigger the bitmap, the better the output quality. I know this is a stupid question but is the printer setup correctly?

The Neil =:)
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2824971
Sharons: did you read my previous post?

TheNiel : please tell me if I am gibbering...

If you scan at a higher res than printer, then you will need to shrink the image to fit the page. You will lose data. Your algorythm will determine how much data you lose, hence the quality of the print.

If you scan at a lower res than printer, then you need to upscale the image, creating pixel data where there was none before. Again, you algorytm for stretching will determine the print quality.

The easiest way is to match your scan and print resolutions.

Scan and print at the same res. No stretching or shrinking. none.

eg If you scan at 9600 DPI, and print it to a 300 DPI printer, you page will now print on 1024 pages. try it !.

0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2824994
Mullet,

Rest assured, you're talking sense (although the chances of scanning at BIGGER than the printed page are remote). It all depends what the printer dpi is set to

The Neil =:)
0
 

Author Comment

by:sharons
ID: 2825951
It seems I was making things way too complicated. I just load the bitmap in a TImage then use StretchDraw and it works fine. I think it's probably a setting on the scanner that fixed it. Thank you.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 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