printing .bmp problem

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Chevron.

I am trying to write a procedure to print 640x480 .bmp at full page width.

To do this I look at the printer resolution, work out what I need to scale the image by to fill the A4 page, width wise, then scale the image before passing it to the printer page. This works well for 360 dpi as I only have to scale the image by a factor of around 4. For 720 dpi or larger the image would need to be scaled by a factor of 9 or more, and doing this causes my program to crash.
Is this a bug, or expected, and is there any other way of doing what I'm trying to acheive?

Thanks in advance
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Hi Chevron,

Without posting any code, it's pretty hard to see what you might be doing wrong.
Anyway, this is the math I use to resize images to print either their exact size or to fill the entire printer width. (Disclaimer: it works fine for me and I have not had any problems with it)

Code: Select all

#pic=1
 
If LoadImage(#pic,"lynx.bmp")
  If PrintRequester() 
    fiximage.f=(ImageWidth()*8.39)/PrinterPageWidth()
 
    imgx.f=ImageWidth()/fiximage
    imgy.f=ImageHeight()/fiximage
    ;ResizeImage(#pic,imgx,imgy)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Chevron.

Thanks for your reply Paul, but I still seem to get the same error when running this code.

Erorr: object not intialised.

On the draw image line in debug
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Chevron,

Maybe this could be caused by your hardware ressources because resizing your image may eat mcuh memory when drawing it.

I noticed when testing images that large ones may cause a crash.

Rgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by JimmyClif.

Paul,

Sorry to dig out an old thread but I was searching for weeks for a nice understandable 'Fit2Page' algo. Yours looks good but can be optimised :)

Code: Select all

;   fillx.f=imgx*(PrinterPageWidth()/imgx)
    fillx.f=PrinterPageWidth() ; as x*(y/x) balances out
But my major question is this line:

Code: Select all

fiximage.f=(ImageWidth()*8.39)/PrinterPageWidth()
Where does the 8.39 come from ?

Thanks,
Jimmy
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> this is the math I use to resize images to print either their exact size or
> to fill the entire printer width. (Disclaimer: it works fine for me and I
> have not had any problems with it)

I just tried Paul's code and it works fine for me when printing to a PDF file
using JAWS PDF Creator, and also works with a Canon BJC-265 SP printer;
but on my Dad's HP LaserJet 6P/6MP PostScript printer all I get is black.
Anyone know if there is an issue printing to PostScript printers (Fred?).
My Dad can obviously print to his HP printer normally with other apps.

(BTW, I too would like to know where the 8.39 figure comes from). :)
Post Reply