TPrinter recent methods PrintImage() and SayText()

TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Mon May 02, 2016 4:00 am

It appears to me that the recently introduced methods PrintImage and SayText of TPrinter class have gone mostly unnoticed.

oPrn:SayText( nRow, nCol, cText, [nWidth], [nHeight], [oFont], [cAlign], [nClrText], [nClrBack] ) --> nLastRow printed
Useful for priting multi-line text. The return value can be used to continue printing next lines.

oPrn:PrintImage( nRow, nCol, uImage, nWidth, nHeight, lStretch, nAlpha, lTransp, lGray ) --> nLastRow printed
uImage can be any image source.

For those who like, I suggest trying this sample program:
Code: Select all  Expand view
#include "fivewin.ch"

//----------------------------------------------------------------------------//
function Main()

   local aText[ 4 ], oPrn, oFont
   local nMargin, nGutter, nWidth, nColWidth
   local nRow, nCol

   TEXT INTO aText[ 1 ]
   Powerful typhoon Koppu ploughed into the northeasten Philppines before dawn on Sunday destroying homes and displacing 10,000 people and whipping up coastal surges four metres high.

   ENDTEXT

   TEXT INTO aText[ 2 ]
   ఉత్తరప్రదేశ్‌లోని నోయిడాలో ఉన్న అమిత్ యూనివర్సిటీలో ఓ తెలుగు విద్యార్ధి దారుణ హత్యకు గురయ్యాడు. స్నేహితులే అతడిని కాల్చి చంపినట్లు తెలుస్తోంది. మృతుడు నల్గొండ పట్టణంలోని శ్రీనగర్ కాలనీకి చెందిన సందేశ్ భాస్కర్ (23)గా గుర్తించారు. సందేశ్ భాస్కర్ నోయిడాలోని అమిత్ యూనివర్సిటీలో బీఎస్సీ మెరైన్ సైన్స్

   ENDTEXT

   TEXT INTO aText[ 3 ]
   I'm hoping that every good film is a commercial film. Every good film should be a commercial film. And my definition of commercial is that if the film goes out and people engage in it and it earns money, then it is a commercial film," said Anurag Kashyap.

   ENDTEXT

   TEXT INTO aText[ 4 ]
   लेखकों द्वारा साहित्य अकादमी सम्मान लौटाने के क्रम में एक नाटकीय मोड़ तब आ गया जब उर्दू के मशहूर शायर मुनव्वर राणा ने टीवी पर सीधे प्रसारण के दौरान अपना साहित्य अकादमी सम्मान लौटा दिया और साथ में एक लाख रूपये का चेक भी दिया। राणा ने घोषणा की कि वह भविष्य में किसी भी तरह का सरकारी सम्मान ग्रहण नहीं करेंगे। समकालीन उर्दू कविता के एक बड़े नाम राणा आज टेलीविजन पर एक कार्यक्रम में भाग ले रहे थे। इसमें कई लेखक और राजनेता भी शामिल हुए। इसी दौरान राणा ने कहा कि उन्होंने अपना सम्मान लौटाने का निर्णय लिया है और वह वर्तमान में देश के हालात से क्षुब्ध हैं। राणा ने कहा

   ENDTEXT

   PRINT oPrn PREVIEW
   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-12 OF oPrn

   nMargin     := Int( 0.1 * oPrn:nHorzRes() )
   nWidth      := 8 * nMargin
   nColWidth   := Int( ( nWidth - nMargin ) / 2 )


   PAGE
   nRow        := 100
   nRow        := oPrn:SayText( nRow, nMargin, aText[ 1 ], nColWidth, nil, oFont )
   nRow        += 20
   nRow        := oPrn:PrintImage( nRow, nMargin, "c:\fwh\bitmaps\olga1.jpg", nColWidth, 2000 )
   nRow        += 40
   nRow        := oPrn:SayText( nRow, nMargin, aText[ 2 ], nColWidth, nil, oFont )
   nRow        += 20
   nRow        := oPrn:PrintImage( nRow, nMargin, "koala.jpg", nColWidth, 1500 )


   nRow        := 100
   nCol        := nMargin + nColWidth + nMargin
   nRow        := oPrn:SayText( nRow, nCol, aText[ 3 ], nColWidth, nil, oFont )
   nRow        += 20
   nRow        := oPrn:PrintImage( nRow, nCol, "eiphil.jpg", nColWidth, nil )
   nRow        += 40
   nRow        := oPrn:SayText( nRow, nCol, aText[ 1 ], nColWidth, nil, oFont )
   nRow        += 20
   nRow        := oPrn:PrintImage( nRow, nCol, "\fwh\bitmaps\alphabmp\design.bmp", nColWidth, 600 )
   nRow        += 40
   nRow        := oPrn:SayText( nRow, nCol, aText[ 4 ], nColWidth, nil, oFont )

   ENDPAGE
   ENDPRINT

return nil

I used some jpg's which are not available in the fwh\samples folder. You may substitute with your own jpgs or other image files.

Image

I hope you will notice much better quality of printing.
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby mastintin » Wed May 04, 2016 7:00 am

Nages.
Is posible add Something similar to this ?
Regards.

Code: Select all  Expand view


METHOD CmSayText( nRow, nCol, cText, nWidth, nHeight, oFont, cAlign, nClrText, nClrBack ) CLASS TPrinter
  local aTmp := ::CmRect2Pix( { nRow, nCol, nWidth, nHeight } )
  local nRow := ::SayText(  aTmp[ 1 ], aTmp[ 2 ], cText, aTmp[ 3 ], aTmp[ 4 ], oFont, cAlign, nClrText, nClrBack )
Return  ( nRow * 25.4 / ::nLogPixelX() ) / 10

METHOD CmPrintImage( uImage, aRect, lTransp, nResizeMode, nAlphaLevel, lGray ) CLASS TPrinter
   local nRow := ::PrintImage( uImage, ::CmRect2Pix( aRect ), lTransp, nResizeMode, nAlphaLevel, lGray )
Return ( nRow * 25.4 / ::nLogPixelX() ) / 10

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Wed May 04, 2016 7:29 am

Mr Manuel

1) Actually I am planning to provide convenient command syntax.
Something like :

@ r, c SAY TO oPrn IMAGE/TEXT ...........SIZE <w>,<h> [INCHES/PIXEL/MM/CM] [ENDING AT <nEndrow>]

2) I am also waiting for feedback from users about the compatibility of the new image function with different printers. For obvious reasons I could test with only one printer. May be I need to add check for device capabilities
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby mastintin » Wed May 04, 2016 8:47 am

Ok.
Mr.Nages.
my feedback....

with oPrn:PrintImage ...
If we use a background image for din a4 ( to lay out an invoice ) .
the image is 1683x1211px 150ppp. == 20,50cm x28.5cm x150ppp ( photoshop data )
The intention is to adjust the image to the paper a4 + - 21x29 cm.

I used these coordinates to highlight the result :

aD := oPrn:Cmtr2Pix( 30,30 )
oPrn:PrintImage( 0, 0, cNombreBMP, aD[1], aD[2], .t. )

No resizes the image never far from a 18x25 more ( printer and screen ) . :(
this is equivalent to 171ppp. image pixel density.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Wed May 04, 2016 9:19 am

Mr Manuel

No resizes the image never far from a 18x25 more ( printer and screen ) . :(
this is equivalent to 171ppp. image pixel density.


I did not understand clearly. Can you please explain in greater detail?
Do you mean lStretch did not work?
Did you want to print the image from edge to edge of the paper?

Any suggestion or advice from you?

Return ( nRow * 25.4 / ::nLogPixelX() ) / 10

Should we not adjust the oPrn:yOffSet ?
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby mastintin » Wed May 04, 2016 10:06 am

Mr. Nages .I will try to create a compact example for this.

nageswaragunupudi wrote:
Return ( nRow * 25.4 / ::nLogPixelX() ) / 10

Should we not adjust the oPrn:yOffSet ?


He has been taken of the code :

METHOD Pix2Cmtr( nRow, nCol ) INLINE ;
( nRow := ( nRow * 25.4 / ::nLogPixelX() ) / 10,;
nCol := ( nCol * 25.4 / ::nLogPixelY() ) / 10,;
{ nRow, nCol } )

Here not oPrn:yOffSet ...
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: TPrinter recent methods PrintImage() and SayText()

Postby mastintin » Wed May 04, 2016 10:58 am

Mr. Nages use testprn2.prg and change :

oPrn:sayBitmap( 1, 1, "..\bitmaps\fivewin.bmp" )
to
oPrn:PrintImage( 1, 1, "..\bitmaps\fivewin.bmp", 2600, 2600 )

or
oPrn:PrintImage( 1, 1, "someimage", 26000, 26000, .t. )
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Wed May 04, 2016 11:17 am

The image does not cover the entire paper.
Is that your point?
That is because I am limiting the width and height.
Let me see.
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Wed May 04, 2016 11:43 am

If I remove ( or comment out ) these two lines
Code: Select all  Expand view
//   nWidth      := Min( nWidth, ::nHorzRes() * 0.9 - nCol )
//   nHeight        := Min( nHeight, ::nVertRes() * 0.9 - nRow )
 

we can print edge to edge.

I sent modified printer.prg to your email.
Please test and advise.
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby norberto » Wed May 04, 2016 12:26 pm

Hi,

These improvements were introduced in what FWH version?

Regards
norberto
 
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Wed May 04, 2016 2:13 pm

FWH 15.09 (Revd Build 4) published in Oct 2015.
There is no change in the code from 15.09(4) till 16.03.
Please see whatsnew.txt for details.
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby mastintin » Wed May 04, 2016 2:18 pm

Mr. Nages ,now is ok for me :D .
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: TPrinter recent methods PrintImage() and SayText()

Postby nageswaragunupudi » Wed May 04, 2016 2:33 pm

Thanks
Regards

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

Re: TPrinter recent methods PrintImage() and SayText()

Postby byte-one » Tue Apr 11, 2017 1:59 pm

Mr. Nages, it seems that PrintImage() on WIN XP only paint black boxes!? Some of my user stay on XP.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TPrinter recent methods PrintImage() and SayText()

Postby byte-one » Mon Apr 17, 2017 1:48 pm

Mr. Nages, is any comment of this? For now i make a call iswinXP() and use SayImage(). But PrintImage() are much better in rendering pictures!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests