Solved

Use scanner as copier

Posted on 2000-05-17
16
487 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
  • 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
 
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 300 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

21 Experts available now in Live!

Get 1:1 Help Now