Solved

own qrImage in delphi 3

Posted on 1998-05-05
13
344 Views
Last Modified: 2010-04-03
Hi,
I'm trying to make a qrimage that uses stretchdib to print
something to enhance greatly the quality of the printed images. My problem is that I can't get the image
to print at the right size specified in the size property
of the components.

Here is the component, it is working except that the print
sizes are not accurate. What can I do ?

thanks for your help.
Here follows the source code:

------------------------------------------------
unit qrji;

interface

uses classes, quickrpt, Qrctrls, windows, graphics, dialogs;

type
     TQRJImg = class(TQRImage)
     public
          constructor Create(AOwner: TComponent); override;
          procedure Print(OfsX, OfsY: integer); override;
     end;

procedure Register;

implementation

procedure DrawImage(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
var
     Header, Bits: Pointer;
     HeaderSize: Integer;
     BitsSize: Longint;
     test: integer;
begin
     GetDIBSizes(ABitmap.Handle, HeaderSize, BitsSize);
     getMem(Header, HeaderSize);
     getMem(Bits, BitsSize);
     try
          GetDIB(ABitmap.Handle, ABitmap.Palette, Header^, Bits^);
          test := StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top,
               DestRect.Right, DestRect.Bottom,
               0, 0, ABitmap.Width, ABitmap.Height,
               Bits, TBitmapInfo(Header^),
               DIB_RGB_COLORS, SRCCOPY);

          if test = 0 then
               MessageDlg('Sorry, but one of your cover will not be printed' + #13 + #10 + 'Maybe of a lack of memory.' + #13 + #10 + 'Try to reduce the printing resolution.'
                    + #13 + #10 + ''
                    + #13 + #10 + 'Go ahead anyway ?', mtError, [mbYes, mbNo], 0);
     finally
          FreeMem(Header);
          FreeMem(Bits);
     end;
end;

constructor TQRJImg.Create(AOwner: TComponent);
begin
     inherited Create(AOwner);
end;

procedure TQRJImg.Print(OfsX, OfsY: integer);
var
//     CalcLeft,
//          CalcTop,
//          CalcRight,
//          CalcBottom: Longint;
//     checked: boolean;
     dest:trect;
begin
     with ParentReport.QRPrinter do
     begin
          with dest do
          begin
               Top := YPos(OfsY + Size.Top);
               Bottom := YPos(OfsY + Size.Top + Size.Height);
               left := XPos(OfsX + Size.Left);
               right := XPos(OfsX + Size.Left + Size.Width);
          end;
          drawImage(Canvas, dest, picture.Bitmap);
     end;
end;

procedure Register;
begin
     RegisterComponents('QReport', [TQRJImg]);
end;

end.

0
Comment
Question by:jeurk
  • 6
  • 6
13 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341381
hi jeurk,

What about streching the picture to printer dimensions, when printing?

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341382
Hi jeurk,

this is some code I've used one day, maybe you can change it to your needs....

var ScaleX, ScaleY : integer;

with metacnvase do begin
 ScaleX := GetDeviceCaps(Printer.Handle, logPixelsX) div PixelsPerInch;
 ScaleY := GetDeviceCaps(Printer.Handle, logPixelsY) div PixelsPerInch;
end;

 ARect:= rect(0,0,MetaPage.Width*ScaleX, MetaPage.Height*ScaleY);

Regards, ZiF.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1341383
Do I understand you right: you want to print stretched images ??

If so, I can suggest you to use the Wang OCXes that have such options.
(-They're free...)

Regards,
bosism@netvision.net.il
0
 
LVL 4

Author Comment

by:jeurk
ID: 1341384
Hi guys,
Did you took a look at my code ?
I am printing stretched images.
All is working right. Except that the printed image has
not the right size.
here:
with ParentReport.QRPrinter do
         begin
              with dest do
              begin
                   Top := YPos(OfsY + Size.Top);
                   Bottom := YPos(OfsY + Size.Top + Size.Height);
                   left := XPos(OfsX + Size.Left);
                   right := XPos(OfsX + Size.Left + Size.Width);
              end;

I'm using qreports functions to get the right sizes.
The params of the print function are OfsX and OfsY those
are the printer coords where I should print. Qreport is giving
them to me.
after that I have to get the right width and height, here I do use
Xpos and Ypos that makes the right conversion for me, like your
code Zif.
What I was asking was, if you would understand it better the me,
let's change My component source code to make it print right.
I don't think we need ocx's or others functions, do we ?

Thanks for the help guys, let's finish the work.

Jeurk.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341385
Maybe I'm stupid, but can you define 'not correct size' better...?
Is the Top place not good, are the widths of the drawing bad?

I can't see what's wrong with your code, ...

      ImRect:=Rect( Xpos(OfsX+Size.Left),
                       Ypos(OfsY+Size.Top),
                       Xpos(OfsX+Size.Left+Size.Width),
                       Ypos(OfsY+Size.Top+Size.Height));

     Canvas.StretchDraw(ImRect, Bitmap);
    or Canvas.Draw(XPos(OfsX+SIze.Left),Ypos(OfsY+Size.Top),Bitmap);

Regards, ZiF.
0
 
LVL 4

Author Comment

by:jeurk
ID: 1341386
Your not stupid Zif ;)
If someone is stupid it must be me ;)
It's the widths of the drawing that are bad,
AMybe you could try the component out and let me
know if you have the same problem,
maybe it's only a problem on my printer ?
Have you tryed it ?
If You try it out make sure you print the thing,
a preview is not enough, the preview differs from the
print.

Please let me know.
Thanks.

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1341387
Hi jeurk,

I've got a component which handles it's printing with QR the same. I have no problems with it... Which printer do you use AND which version of QR do you use?

Regards, ZIF.
0
 
LVL 4

Author Comment

by:jeurk
ID: 1341388
Hi Zif,
can I take a look at that component ?
mailto://knipjo@citeweb.net

Thanks
0
 
LVL 4

Author Comment

by:jeurk
ID: 1341389
by the way,
I'm using qr 2.0g and delphi 3.02 ;)

0
 
LVL 4

Author Comment

by:jeurk
ID: 1341390
To better illustrate my problem, I made a little project that I
can send to you if you want.

You'll have to install my component.
After that look what it is printing. Normally the too images should
print at the same size, but they don't. The first is my component
the second is the standard qrimage component. So what shall I do
for them to print at the same size ?

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341391
Hi jeurk,

The component is QR component of TeeChart

Mmm, I think you better download QR 2.0k ... I know of some bugs in QR of printing pictures.

No problem, you may send me the code... (But I'm going home now, so I can't check it till tomorrow). Tom.Deprez@uz.kuleuven.ac.be

Regards, Zif.
0
 
LVL 4

Author Comment

by:jeurk
ID: 1341392
Hello zif,
The prooblem is no more,
I installed QR2.0j and now the qrimage is doing what I want from his own.
Let's answer that question so I can give you the points. You gave time, you earn points ;)
(thank you too matvey)
Regards.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1341393
Thanks jeurk,

To answer the qsuestion :

Mmm, I think you better download QR 2.0k ... I know of some bugs in QR of printing pictures in earlier versions.

PS. Why j instead of newer version k? k is already out of beta.

Regards, ZiF.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
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…

743 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

8 Experts available now in Live!

Get 1:1 Help Now