New topic: 

Make image in Canvas larger

<http://forums.realsoftware.com/viewtopic.php?t=43860>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        rhartz          Post subject: Make image in Canvas largerPosted: 
Thu May 03, 2012 11:28 am                         
Joined: Mon Feb 20, 2012 3:16 pm
Posts: 42                Hi.  I went by the example project in RB to make a 
ReportViewer for my app.  The run report comes out a little small and difficult 
to read.  How do you "zoom in" to make it look larger in the Canvas area?  I 
tried stretching the Canvas and even changed the Me.Width below, but it's not 
displaying any larger.
This is the code in Canvas1.Paint
If mCurrentPicture <> Nil Then
  g.DrawPicture( mCurrentPicture, 0, 0, Me.Width, Me.Height, 0, 
Scrollbar1.Value, Me.Width, Me.Height )
Else
  g.DrawRect( 0, 0, Me.Width, Me.Height )
End If
   
                             Top                charonn0          Post subject: 
Re: Make image in Canvas largerPosted: Thu May 03, 2012 12:04 pm                
                 
Joined: Mon Apr 02, 2007 2:08 am
Posts: 741
Location: San Francisco, CA, USA                Change this the first Me.Width, 
Me.Height with the size you want the finished product to be:
//This
g.DrawPicture(mCurrentPicture, 0, 0, Me.Width, Me.Height, 0, Scrollbar1.Value, 
Me.Width, Me.Height)


//Becomes this.
//This doubles the size of the output image
g.DrawPicture(mCurrentPicture, 0, 0, Me.Width * 2, Me.Height * 2, 0, 
Scrollbar1.Value, Me.Width, Me.Height)



Here's a handy function I wrote some time ago to scale images:
Function Scale(Extends Source As Picture, Ratio As Double) As Picture
  //Returns a scaled version of the passed Picture object.
  //A ratio of 1.0 is 100% (no change,) 0.5 is 50% (half size) and so forth.
  
  If Ratio = 1.0 Then Return Source  //No change, so why bother?
  
  Dim wRatio, hRatio As Double
  wRatio = (Ratio * Source.width)
  hRatio = (Ratio * Source.Height)
  If wRatio = Source.Width And hRatio = Source.Height Then Return Source
  Dim photo As New Picture(wRatio, hRatio, Source.Depth)
  Photo.Graphics.DrawPicture(Source, 0, 0, Photo.Width, Photo.Height, 0, 0, 
Source.Width, Source.Height)
  Return photo
  
  Exception
  Return Source
End Function
      
_________________
Boredom Software  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to