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

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

Postby hua » Tue Jan 26, 2010 4: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby driessen » Tue Jan 26, 2010 9:43 am

The width and height of the bitmap can change from one printer to another.

The code I use is :
Code: Select all  Expand view
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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

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

Postby hua » 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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby James Bott » Tue Jan 26, 2010 6: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

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

Postby hua » Wed Jan 27, 2010 8: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby hua » Wed Jun 30, 2010 5: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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby James Bott » Wed Jun 30, 2010 2: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: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

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

Postby Carlos Mora » 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"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

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

Postby James Bott » Mon Jul 05, 2010 5:50 pm

Carlos,

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

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

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

Postby hua » Tue Jul 06, 2010 3:11 am

James,
Thanks for the reply.

James, Carlos, currently I implemented the technique this way

Code: Select all  Expand view

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
hua
 
Posts: 1038
Joined: Fri Oct 28, 2005 2:27 am

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

Postby RAMESHBABU » Wed Feb 16, 2011 5: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.

Image

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

Regards,

- Ramesh Babu P
Last edited by RAMESHBABU on Thu Feb 17, 2011 7:15 am, edited 1 time in total.
User avatar
RAMESHBABU
 
Posts: 615
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

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

Postby anserkk » Thu Feb 17, 2011 4: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
User avatar
anserkk
 
Posts: 1329
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

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

Postby RAMESHBABU » Thu Feb 17, 2011 5: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
User avatar
RAMESHBABU
 
Posts: 615
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

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

Postby nageswaragunupudi » Thu Feb 17, 2011 6:12 am

Dear Ramesh

Use imageshack.us
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10253
Joined: Sun Nov 19, 2006 5:22 am
Location: India

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

Postby RAMESHBABU » Thu Feb 17, 2011 7:19 am

Dear Mr.Rao.

Thank you very much.

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Adolfo and 17 guests