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

x
?
Solved

own qrImage in delphi 3

Posted on 1998-05-05
13
Medium Priority
?
366 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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 100 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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