Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Sep 22, 2019 10:05 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Print Landscape in Linux
PostPosted: Wed Apr 22, 2009 5:59 pm 
Offline
User avatar

Joined: Thu Nov 15, 2007 4:07 am
Posts: 313
Location: 't Zand, The Netherlands
Ok, I finally found out how to do landscape printing with RB in Linux. In an earlier topic (viewtopic.php?f=8&t=26774) I already mentioned RB's print limitations in Linux. RS confirmed this and said it is on their TODO list for a future version of RB.

To do landscape printing, I used a picture and rotated it 90 degrees counter clockwise:
Dim p As Picture
Dim g As Graphics

g = OpenPrinterDialog
If g <> Nil Then
p = New Picture(g.Width, g.Height, 16)
DrawMyGraphic p.Graphics
g.DrawPicture Landscape(p), 0, 0
End If
This is the Landscape function:
Function Landscape (Pict As Picture)
Dim o As Object2D
Dim p As Picture
Dim dx, dy As Double

p = New Picture(Pict.Width, Pict.Height, Pict.Depth)

dx = p.Width / 1.39
dy = p.Height / 1.58

o = New PixmapShape(Pict)
o.Rotation = -90 / 57.2958 //90 Degrees in radians
p.Graphics.ForeColor = &cffffff
p.Graphics.FillRect 0, 0, p.Width, p.Height
p.Graphics.DrawObject o, dx, dy
p.Graphics.ForeColor=&c000000

Return p
End Function
dx and dy are approximations, and I am not sure how to precisely calculate them. Anyone?

I have not yet tested the other way around (landscape to portrait).

Frank

_________________
Debian Sqeeze - Real Studio 2011r4
You have to have a little programming fun every day!


Top
 Profile  
Reply with quote  
 Post subject: Re: Print Landscape in Linux
PostPosted: Thu Apr 23, 2009 1:06 am 
Offline
User avatar

Joined: Wed Nov 15, 2006 3:50 pm
Posts: 2353
Location: England
Here is some code that tomis submitted a while back.
Since you are doing 90 degree rotation, there is no loss of pixels,

Its up to you whether the results are fast enough..
Dim target As Picture
Dim sIn,sOut as RGBSurface
Dim x,y,w,h As Integer

sIn=source.RGBsurface
target = NewPicture(source.Height,source.Width,32)
sOut=target.RGBsurface

w=thepic.width-1
h=thepic.height-1

For y=0 to h
For x=0 to w
sOut.Pixel(y,x)=sIn.Pixel(x,y)
Next
Next
//target now holds the rotated image


Top
 Profile  
Reply with quote  
 Post subject: Re: Print Landscape in Linux
PostPosted: Thu Apr 23, 2009 4:06 am 
Offline
User avatar

Joined: Thu Nov 15, 2007 4:07 am
Posts: 313
Location: 't Zand, The Netherlands
Thanks Jeff. I will try and see which one is faster, although I believe that preservation of pixels is the way to go.

Frank

_________________
Debian Sqeeze - Real Studio 2011r4
You have to have a little programming fun every day!


Top
 Profile  
Reply with quote  
 Post subject: Re: Print Landscape in Linux
PostPosted: Thu Apr 23, 2009 6:12 am 
Offline
User avatar

Joined: Thu Nov 15, 2007 4:07 am
Posts: 313
Location: 't Zand, The Netherlands
Ok, I tried Tomis' code and it did rotate but also flipped the picture horizontally.

The iterations cannot be used for both the source and the target as the target must count y from Height downward:
For sY = 0 To h
tY = w
For sX = 0 To w
sOut.Pixel(tX, tY) = sIn.Pixel(sX, sY)
tY = tY - 1
Next
tX = tX + 1
Next
However, this only works if the graphics to be printed is already within landscape dimensions. This function then returns a 'landscaped' picture in portrait fomat. :roll: This is the way to go right now since the PrinterSetup class cannot be used and the Landscape property is always set to False. But it allows printing landscaped graphics in Linux!

I noticed that rotating pixel by pixel is a bit slower than using PixmapShape. However, the pixels are now preserved and there is no need to calculate a rotation point.

Thanks Tomis for your cue!

Frank

_________________
Debian Sqeeze - Real Studio 2011r4
You have to have a little programming fun every day!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group