# Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
 It is currently Sun Feb 23, 2020 12:06 am

 All times are UTC - 5 hours

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Print Landscape in LinuxPosted: Wed Apr 22, 2009 5:59 pm

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 PictureDim g As Graphicsg = OpenPrinterDialogIf g <> Nil Then  p = New Picture(g.Width, g.Height, 16)  DrawMyGraphic p.Graphics  g.DrawPicture Landscape(p), 0, 0End 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 pEnd 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

 Post subject: Re: Print Landscape in LinuxPosted: Thu Apr 23, 2009 1:06 am

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 PictureDim sIn,sOut as RGBSurfaceDim x,y,w,h As IntegersIn=source.RGBsurfacetarget = NewPicture(source.Height,source.Width,32)sOut=target.RGBsurfacew=thepic.width-1h=thepic.height-1For y=0 to h  For x=0 to w    sOut.Pixel(y,x)=sIn.Pixel(x,y)  NextNext//target now holds the rotated image`

Top

 Post subject: Re: Print Landscape in LinuxPosted: Thu Apr 23, 2009 4:06 am

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

 Post subject: Re: Print Landscape in LinuxPosted: Thu Apr 23, 2009 6:12 am

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 + 1Next`
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. 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.

Frank

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

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC - 5 hours

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

Search for:
 Jump to:  Select a forum ------------------ General    General    Getting Started    Networking    Databases    Visual Basic to REAL Studio Conversion    Games    Plugins    Tips    Web Control SDK Platform Specific    Windows    Macintosh    Linux    Web Other Topics    Announcements    Off-Topic    Third Party Add-ons