Printing of Images on Printers having different resolutions

Printing of Images on Printers having different resolutions

Postby RAMESHBABU » Tue Oct 31, 2006 2:51 pm

Hi all

Can anybody guide me how to print the images exactly at the desired
row, col co-ordinates (whether in pixels or Cm) on different printers with different resolutions.

With the following code I got this out using different printers with different
printer resolutions:

Image

Code: Select all  Expand view
#include "FiveWin.ch"

#define PAD_LEFT      0
#define PAD_RIGHT     1
#define PAD_CENTER    2

FUNCTION Main()

LOCAL oPrn, oPen, oFont, oFont1, oFont2, oFont3
LOCAL pno := 1, nLs := 0, n, nLinI, nColI, nLinF, nColF,nColL
LOCAL aRowCol := {}, aData := {}

******

FOR n = 1 TO 90
    AADD(aData,{"1234","12345",REPLI("A",20),REPLI("B",20), "C", REPLI("D",8),REPLI("E",8), "99/99/9999", "99/99/9999"})
NEXT

PRINT oPrn NAME "Testing Windows Printing" PREVIEW FROM USER

      DEFINE PEN  oPen   WIDTH  2 OF oPrn
      DEFINE FONT oFont  NAME "Arial Bold"   SIZE 0, -16 OF oPrn
      DEFINE FONT oFont1 NAME "Arial Italic" SIZE 0, - 8 OF oPrn
      DEFINE FONT oFont2 NAME "Arial Bold"   SIZE 0, - 9 OF oPrn
      DEFINE FONT oFont3 NAME "Arial"        SIZE 0, - 8 OF oPrn

      oPrn:SetPage(9)   
      oPrn:SetPortrait()

      PAGE
 
         nLinI := 03.75
         nLinF := 27.25

         IF .NOT. OS_IsWinXP()
            nColI := 01.00
            nColF := 20.75
            nColL := 00.20
         ELSE
            nColI := 00.70
            nColF := 20.25
            nColL := 00.45
         ENDIF
         
         oPrn:Cmtr2Pix(@nLinI, @nColI)
         oPrn:cmtr2Pix(@nLinF, @nColF)

         aRowCol := oPrn:Cmtr2Pix(1,1)
         
         oPrn:SayBitmap(aRowCol[1], aRowCol[2],"c:\fwh\bitmaps\fivewin.bmp") //, 131, 168)

         oPrn:CmSay(1.00, 10.50-nColL, "NAME OF THE COMPANY", oFont,,CLR_BLACK,,PAD_CENTER )
         oPrn:CmSay(1.55, 10.50-nColL, "This is the place where address of the company is printed", oFont1,,CLR_BLACK,,PAD_CENTER )
         oPrn:CmSay(2.15, 10.50-nColL, "THIS IS THE HEADING OF REPORT", oFont2,,CLR_BLACK,,PAD_CENTER )

         oPrn:Box(nLinI, nColI, nLinF, nColF, oPen )
         oPrn:Box(nLinI-(oFont2:nHeight()*2.75), nColI, nLinI+(oFont2:nHeight()*.75), nColF, oPen  )

         oPrn:CmSay(3.05,01.35-nColL,"SL.",  oFont2)
         oPrn:CmSay(3.05,02.15-nColL,"AAAA", oFont2)
         oPrn:CmSay(3.05,03.25-nColL,"BBBB", oFont2)
         oPrn:CmSay(3.05,04.55-nColL,"CCCCCCCCCCCCCCCCC", oFont2)   
         oPrn:CmSay(3.05,08.60-nColL,"DDDDDDDDDDDDD", oFont2)   
         oPrn:CmSay(3.05,12.70-nColL,"EEE",     oFont2)   
         oPrn:CmSay(3.05,13.60-nColL,"FFFFFFF", oFont2)   
         oPrn:CmSay(3.05,15.70-nColL,"GGGGGGG", oFont2)   
         oPrn:CmSay(3.05,17.60-nColL,"HHHHHH",  oFont2)   
         oPrn:CmSay(3.05,19.25-nColL,"KKKKKK",  oFont2)   

         oPrn:CmSay(3.50,01.35-nColL,"NO.", oFont2)
         oPrn:CmSay(3.50,02.15-nColL,"AAA", oFont2)
         oPrn:CmSay(3.50,03.25-nColL,"BBB", oFont2)

         FOR n = 1 TO LEN(aData)
             
             oPrn:CmSay(4.50+nLs,01.35-nColL, STR(n,3,0), oFont3 )
             oPrn:CmSay(4.50+nLs,02.15-nColL, aData[n,1],oFont3)
             oPrn:CmSay(4.50+nLs,03.25-nColL, aData[n,2],oFont3)
             oPrn:CmSay(4.50+nLs,04.55-nColL, aData[n,3],oFont3)
             oPrn:CmSay(4.50+nLs,08.60-nColL, aData[n,4],oFont3)
             oPrn:CmSay(4.50+nLs,12.85-nColL, aData[n,5],oFont3)
             oPrn:CmSay(4.50+nLs,13.50-nColL, aData[n,6],oFont3)
             oPrn:CmSay(4.50+nLs,15.70-nColL, aData[n,7],oFont3)
             oPrn:CmSay(4.50+nLs,17.60-nColL, aData[n,8],oFont3)
             oPrn:CmSay(4.50+nLs,19.25-nColL, aData[n,9],oFont3)
                 
             nLs := nLs + .50

             IF nLs > 22

                oPrn:CmSay(27.25,20.90-nColL,"Contd .. "+LTRIM(STR(pno))+"/", oFont3,,CLR_BLACK,,PAD_RIGHT)

                ENDPAGE

                PAGE

                pno ++

                oPrn:CmSay(1.00, 10.50-nColL, "Page No. "+LTRIM(STR(pno)), oFont2,,CLR_BLACK,,PAD_CENTER )     
                oPrn:CmSay(1.80, 10.50-nColL, "THIS IS THE HEADING OF REPORT", oFont2,,CLR_BLACK,,PAD_CENTER )
                     
                oPrn:Box(nLinI, nColI, nLinF, nColF, oPen )
                oPrn:Box(nLinI-(oFont2:nHeight()*2.75), nColI, nLinI+(oFont2:nHeight()*.75), nColF, oPen  )

                oPrn:CmSay(3.05,01.35-nColL,"SL.",   oFont2)
                oPrn:CmSay(3.05,02.15-nColL,"AAAA",  oFont2)
                oPrn:CmSay(3.05,03.25-nColL,"BBBB",  oFont2)
                oPrn:CmSay(3.05,04.55-nColL,"CCCCCCCCCCCCCCCC", oFont2)   
                oPrn:CmSay(3.05,08.60-nColL,"DDDDDDDDDDDDD", oFont2)   
                oPrn:CmSay(3.05,12.70-nColL,"EEE",     oFont2)   
                oPrn:CmSay(3.05,13.60-nColL,"FFFFFFF", oFont2)   
                oPrn:CmSay(3.05,15.70-nColL,"GGGGGGG", oFont2)   
                oPrn:CmSay(3.05,17.60-nColL,"HHHHHH",  oFont2)   
                oPrn:CmSay(3.05,19.25-nColL,"KKKKKK",  oFont2)   

                oPrn:CmSay(3.50,01.35-nColL,"NO.", oFont2)
                oPrn:CmSay(3.50,02.15-nColL,"AAA", oFont2)
                oPrn:CmSay(3.50,03.25-nColL,"BBB", oFont2)

                nLs := 0

              ENDIF

         NEXT

      ENDPAGE

ENDPRINT

RETURN nil



Thanks in advance

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby R.F. » Tue Oct 31, 2006 4:44 pm

Your error is here:

oPrn:SayBitmap(aRowCol[1], aRowCol[2],"c:\fwh\bitmaps\fivewin.bmp") //, 131, 168)

4th and 5th parameter are the SIZE of the image, (131,168) you have to transform the size into centimeters (the same way you did with the coordinates of the position.)
Saludos
R.F.
R.F.
 
Posts: 840
Joined: Thu Oct 13, 2005 7:05 pm

Postby James Bott » Tue Oct 31, 2006 5:59 pm

Ramesh,

I find that often print drivers are inaccurate. They don't report the proper values for width, height, and x and y offsets (non-printable areas). So first I would check these.

oPrn:nXOffset
oPrn:nYOffset

Also check:
oPrn:nVertSize()
oPrn:nHorzSize()
oPrn:nVertRes()
oPrn:nHorzRes()

To see if they are accurate.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby RAMESHBABU » Wed Nov 01, 2006 4:23 am

Thank you Mr.Rene and Thank you Mr.James

I am testing it now after conversion of Bitmap's height and width into
centimeters.

Regards to both of you

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Roger Seiler » Thu Nov 02, 2006 3:46 pm

Rene,

Did you mean to say "trnasform the size into pixels" instead of "transform the size into centimeters"?

Here is what you said:

"4th and 5th parameter are the SIZE of the image, (131,168) you have to transform the size into centimeters (the same way you did with the coordinates of the position.)"

This appears to be how the coordinates of the position are set in the code:

aRowCol := oPrn:Cmtr2Pix(1,1)

The TPrinter method Cmtr2Pix() apparently transforms a number from centimeters into pixels instead of from pixels into centimeters.

Although TPrinter has a method to convert pixels into inches, it doesn't seem to have a method to convert pixels into centimeters (which one could easily create).

If you are correct that the dimensional values of the bitmap have to be given in centimeters in order to properly show the bitmap at the same size regardless of printer resolution, this is an important concept for us to understand. (I've had to wrestle with it myself.) But if so, apparently Cmtr2Pix() isn't the way to make that transformation - another method is needed.

- Roger
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Postby Roger Seiler » Thu Nov 02, 2006 3:49 pm

Rene,

Did you mean to say "transform the size into pixels" instead of "transform the size into centimeters"?

Here is what you said:

"4th and 5th parameter are the SIZE of the image, (131,168) you have to transform the size into centimeters (the same way you did with the coordinates of the position.)"

This appears to be how the coordinates of the position are set in the code:

aRowCol := oPrn:Cmtr2Pix(1,1)

The TPrinter method Cmtr2Pix() apparently transforms a number from centimeters into pixels instead of from pixels into centimeters.

Although TPrinter has a method to convert pixels into inches, it doesn't seem to have a method to convert pixels into centimeters (which one could easily create).

If you indeed meant that the dimensional values of the bitmap have to be given in centimeters in order to properly show the bitmap at the same size regardless of printer resolution, this is an important concept for us to understand. (I've had to wrestle with it myself.) But if so, apparently Cmtr2Pix() isn't the way to make that transformation - another method is needed.

- Roger
User avatar
Roger Seiler
 
Posts: 223
Joined: Thu Dec 01, 2005 3:34 pm
Location: Nyack, New York, USA

Re: Printing of Images on Printers having different resoluti

Postby Enrico Maria Giordano » Thu Nov 02, 2006 4:03 pm

Code: Select all  Expand view
         aRowCol := oPrn:Cmtr2Pix(1,1)
         aSize   := oPrn:Cmtr2Pix(1.5,1.5)
         
         oPrn:SayBitmap(aRowCol[1], aRowCol[2],"c:\fwharbour\bitmaps\fivewin.bmp", aSize[2], aSize[1])


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 97 guests