Printing JPGs using TPrinter

Printing JPGs using TPrinter

Postby James Bott » Thu Dec 27, 2007 4: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

Code: Select all  Expand view
// 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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Printing JPGs using TPrinter

Postby Richard Chidiak » Thu Dec 27, 2007 5: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby James Bott » Thu Dec 27, 2007 5:38 am

Richard,

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

James


Code: Select all  Expand view
#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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby nageswaragunupudi » Thu Dec 27, 2007 4: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Thu Dec 27, 2007 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Fri Dec 28, 2007 3: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 75 guests