FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Printing JPGs using TPrinter
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Printing JPGs using TPrinter
Posted: Thu Dec 27, 2007 04:12 AM
I am trying to print a JPG on a report using TPrinter. I get nothing displayed in the preview. Bitmaps work.

I also found that you MUST use REDEFINE to get an oImage object.

Below is my code. Any suggestions?

James

// Test Printing JPB image

#include "FiveWin.ch"
#include "image.ch"


//----------------------------------------------------------------------------//

function Main()
   local oPrn, oImage, cFile:="fivewin.jpg"

   //oImage:= TImage():new(1,1,150,150,,cFile ) // oImage is nil

   //@ 0,0 image oImage file cFile  // oImage is nil

   //@ 0, 0 IMAGE oImage SIZE 150, 150 OF oPrn // oImage is nil

   oImage:= TImage():redefine(,cFile,oPrn) // oImage is object

   //msgInfo( valtype( oImage ) )

   PRINT oPrn PREVIEW
      oImage:oWnd:= oPrn
      PAGE

         //oPrn:sayBitmap( 200, 200, cFile) // works with bitmap

         oPrn:SayImage( 20, 20, oImage )  // nothing shows

         oPrn:say(500,200, "Text goes here.")

      ENDPAGE
   ENDPRINT

   oImage:end()

return nil

//----------------------------------------------------------------------------//
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Printing JPGs using TPrinter
Posted: Thu Dec 27, 2007 05:18 AM

James

This way works

oIMAGE := TIMAGE():Define(,DIMAGE)
OPRN:SAYIMAGE(LineIMP,ColIMP,OIMAGE,LARGE,Height)
OIMAGE:END()

Hth

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Printing JPGs using TPrinter
Posted: Thu Dec 27, 2007 05:38 AM
Richard,

Thanks for the response--now it is working! Here is my revised code.

James


#include "FiveWin.ch"
#include "image.ch"


//----------------------------------------------------------------------------//

function Main()
   local oPrn, oImage, cFile:="fivewin.jpg"

   oImage:=TImage():define(,cFile)

   PRINT oPrn PREVIEW
    
      PAGE

         oPrn:SayImage( 20, 20, oImage, 100, 100 ) 

         oPrn:say(500,200, "Text goes here.")

      ENDPAGE
   ENDPRINT

   oImage:end()

return nil
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Printing JPGs using TPrinter
Posted: Thu Dec 27, 2007 04:25 PM

Can we, instead of reading from a disk file, assign the buffer read from a memo field ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Printing JPGs using TPrinter
Posted: Thu Dec 27, 2007 06:10 PM

Nageswararao,

You may read it from the memo, then create a temporary file and load it from there. Finally erase the temp file.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Printing JPGs using TPrinter
Posted: Fri Dec 28, 2007 03:01 AM
Mr Antonio

I confess I am not good at FreeImage API. But I see these functions and write up in documentation.


Memory I/O streams
Memory I/O routines use a specialized version of the FreeImageIO structure, targeted to save/load FIBITMAP images to/from a memory stream. Just like you would do with a file stream. Memory file streams support loading and saving of FIBITMAP in a memory file (managed internally by FreeImage). They also support seeking and telling in the memory file.
Examples of using these functions would be to store image files as blobs in a database, or to write image files to a Internet stream.
............
..........
FreeImage_LoadFromMemory
DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0));
This function does for memory streams what FreeImage_Load does for file streams.
..........

I think it should be possible to extend the TImage class to read from memory.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion