Printing JPGs using TPrinter

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

Printing JPGs using TPrinter

Post by James Bott »

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

Code: Select all

// 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

//----------------------------------------------------------------------------//
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Printing JPGs using TPrinter

Post by Richard Chidiak »

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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Richard,

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

James

Code: Select all

#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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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

G. N. Rao.
Hyderabad, India
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
Post Reply