FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour What's the right technique using oPrn:SayBitmap()?
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

What's the right technique using oPrn:SayBitmap()?

Posted: Tue Jan 26, 2010 04:13 AM

Recently, I tried using oPrn:SayBitmap() to print a bitmap. After adjusting the width and height passed to :SayBitmap(), I got a look that I'm satisfied with during preview. For testing sake, I changed the printer from an inkjet to a dot-matrix and to my horror the bitmap has become very big.

Obviously I'm missing something here. What's the right technique to have the same look, irregardless of the printer that is in use?

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Tue Jan 26, 2010 09:43 AM
The width and height of the bitmap can change from one printer to another.

The code I use is :
Code (fw): Select all Collapse
oPrn:SayBitMap(0,0,"TEST.BMP",cWidth,cHeight)
This code is working fine here.

You must make the width and height variable if you want to use different printers.

Good luck.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Tue Jan 26, 2010 12:19 PM

Thanks for the reply Michel.

Isn't there any logic that we can apply to get some sort of ratio so we wouldn't have to maintain a database of different width and height for different printers?

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Tue Jan 26, 2010 06:50 PM

Hua,

Maybe these are what you need.

nHeightPixels := Max( 0, ( nHeightInches * oPrn:nVertRes() / (oPrn:nVertSize() / 25.4 )) )
nWidthPixels := Max( 0, ( nWidthInches * oPrn:nHorzRes() / (oPrn:nHorzSize() / 25.4 )) )

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Wed Jan 27, 2010 08:55 AM

Thanks James.

I'll give it a try and update you about it later

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Wed Jun 30, 2010 05:34 AM

James,
Works like a charm, thank you :)

I'd like to understand the logic though. So James, at your convenience, if you could elaborate a bit on the logics used?

Thank you again.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Wed Jun 30, 2010 02:06 PM
Hua,

sayBitmap( nRow, nCol, cBitmap, nWidth, nHeight, nRaster )

nRow, nCol, nWidth, and nHeight are in pixels. Each printer may have a different resolution, i.e. pixels per inch, so you have to calculate these values for each printer.

Actually there is another issue. Each printer may have a different vertical and horizontal "offset." These are the sections of the page along the borders that the printer cannot print on. Like resolution, these offsets may be different for each printer.

I forgot to include these offsets in my calculations. However, you can use the built in method in TPrinter which does include these offsets. See the Inch2Pix( nRow, nCol) method of TPrinter. It returns an array {nRow, nCol}. So you could do something like:

Code (fw): Select all Collapse
oPrn:sayBitmap( oPrn:Inch2Pix(nRow, nCol):[1], ;
  oPrn:Inch2Pix(nRow, nCol):[2], ;
  cBitmap, ;
  oPrn:Inch2Pix(nWidth, nHeight):[1], ;
  oPrn:Inch2Pix(nWidth, nHeight):[2] )


Where nRow, nCol, nWidth, nHeight are all in inches.

There are also Cmtr2Pix() and Mmtr2Pix() methods if you prefer to use those.

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Mon Jul 05, 2010 10:53 AM
Hi James,

let me make an observation: You are doing right NOT using oPrn:Inch2Pix(), because this function adjust coordinates only. The way you did is right.
If you want to use a method, check oPrn:SizeInch2Pix(), the last one in TPrinter (as off FWH9.04)

Best regards
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Mon Jul 05, 2010 05:50 PM

Carlos,

Thanks for pointing that out--I should have tested it.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Tue Jul 06, 2010 03:11 AM
James,
Thanks for the reply.

James, Carlos, currently I implemented the technique this way

Code (fw): Select all Collapse
static nTRow, nTCol, nHeightPixels, nWidthPixels

function printForm()
    PRINTER oPrn PREVIEW NAME cTitl to zPrinter
    PrepImage(oPrn)
    .
    .
   oPrn:SayBitmap(nTRow, nTCol, "perkeso", nWidthPixels, nHeightPixels)
   .
   .
return nil

static function PrepImage(oPrn)
  // calculate the row, col to print and the bitmaps width and height in pixels
  local oBmp := TBitmap():define("perkeso") // to be used to get height to width ratio later
  local nInchWid := 0.826771654 // 21mm
  local nInchHgt

  nWidthPixels := Max( 0, ( nInchWid * oPrn:nHorzRes() / (oPrn:nHorzSize() / 25.4 )) )
  nInchHgt := nInchWid * oBmp:nHeight() / oBmp:nWidth()
  nHeightPixels := Max( 0, ( nInchHgt * oPrn:nVertRes() / (oPrn:nVertSize() / 25.4 )) )

  nTRow := 0.669291339 // in inches - 22mm
  nTCol := 0.354330709
  oPrn:Inch2Pix(@nTRow, @nTCol)

  oBmp:end()
return nil
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Wed Feb 16, 2011 05:54 PM
Hello Friends,

I am trying to print a Logo on a dull background image.
Both the graphics (Logo as well as the background) are .BMP files.

When I used oPrn:SayBitMap(....), The Logo BMP file is not printed
Transparent on the background. The Logo is printed with a white
square box on the dull background as shown here.



Can anybody guide me how to print the Logo transparent on an
another BMP file.

Regards,

- Ramesh Babu P
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Thu Feb 17, 2011 04:41 AM

Dear MR.Ramesh,

Did you try oPrn:SayImage() ? What about the Logo.Bmp ? Does it have an Alpha channel ?.

oPrn:SayImage( nRow, nCol, oImage, nWidth, nHeight, nRaster, lStretch, nAlphaLevel, nAlign )

This is just an idea

What I am suggesting is an alternative way. I am sure that this not the solution that you are looking for, but this trick may serve your purpose.

You have both the BMP files ie the Logo.Bmp and BackGround.Bmp
Use any graphic tools For eg. PixelFormer (Freeware) to place the Logo.BMP on the Background.Bmp and save this as a new file LogoWithBackGround.Bmp

Later you can use the LogoWithBackGround.Bmp as usual with oPn:SayBitmap

Regards
Anser

Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Thu Feb 17, 2011 05:44 AM

Dear Anser Bhai,

>>Does it have an Alpha channel ?.

No. It is a plain BMP file.

>>Use any graphic tools For eg. PixelFormer (Freeware) to place the Logo.BMP on the Background.Bmp and save this as a new file LogoWithBackGround.Bmp

If no solution is found, this is only the left out option.

BTW, previously I used to use HYPERUPLOAD.COM to publish images in our forum. Now that site is no more working. Can you suggest any alternative site ?

Regards to you,

  • Ramesh Babu P
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Thu Feb 17, 2011 06:12 AM

Dear Ramesh

Use imageshack.us

Regards



G. N. Rao.

Hyderabad, India
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM

Re: What's the right technique using oPrn:SayBitmap()?

Posted: Thu Feb 17, 2011 07:19 AM

Dear Mr.Rao.

Thank you very much.

  • Ramesh