New topic: Mysterious Mysteries of Picture & WebImageView
<http://forums.realsoftware.com/viewtopic.php?t=45806> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message Jason_Adams Post subject: Mysterious Mysteries of Picture & WebImageViewPosted: Sun Nov 04, 2012 7:41 pm Joined: Fri Nov 10, 2006 4:10 pm Posts: 1703 Location: Michigan, USA I created a subclass of the WebImageView called WebImageViewPlus (I like to shake things up). The subclass has a computed property, Image As Picture. When Image is Set or the control is resized, the DrawPicture sub is called: Select Case Scaling Case Int32(ScaleType.Stretch) Dim Stretch As New Picture (Me.Width, Me.Height, 32) Stretch.Graphics.DrawPicture (mImage, 0, 0, Me.Width, Me.Height, 0, 0, mImage.Width, mImage.Height) Picture = Stretch Case Int32(ScaleType.Frame) Dim FitImage As New Picture (Me.Width, Me.Height, 32) Dim Frame As Picture Dim Width, Height As Integer FitImage.Graphics.ForeColor = BackgroundColor FitImage.Graphics.FillRect(0, 0, FitImage.Width, FitImage.Height) If (mImage.Width - Me.Width) > (mImage.Height - Me.Height) Then Width = Min(mImage.Width, Me.Width) Height = mImage.Height * (Width / mImage.Width) Else Height = Min(mImage.Height, Me.Height) Width = mImage.Width * (Height / mImage.Height) End If Frame = New Picture (Width, Height, 32) Frame.Graphics.DrawPicture(mImage, 0, 0, Frame.Width, Frame.Height, 0, 0, mImage.Width, mImage.Height) FitImage.Graphics.DrawPicture(Frame, (Me.Width / 2) - (Width / 2), (Me.Height / 2) - (Height / 2)) Picture = FitImage End Select Basically, if the Scaling property is set to Stretch, is fits the Image picture into the control, permitting distortion. Conversely, if Frame is selected, the ratio of the Image is preserved, and it's fit with vertical/horizontal centering into the control. It works pretty good. I have a problem, though, where if I do MyImageView.Image = SomePicturePlacedInTheIDE, it works great. But I'm using a Picture generated by the MBS ChartDirector plugin. The chart looks great, but for some reason I'm getting nothing when I try to DrawPicture using the passed Image. If I do MyImageView.Picture = MyCDChart (notice I'm using the ImageView.Picture property) it works as it normally would, but the chart is too big, so I only see the corner of it. If I break at the Frame.Graphics.DrawPicture(..) line, I clearly see that I'm not drawing from mImage properly. I'm highly suspicious that there's a bug sneaking around here somewhere, but I wanted to see if someone spotted an obvious issue in my code. And, yes, if I view the contents of mImage, it's exactly what it ought to be. Thanks! _________________ Windows 7 Ultimate x64 Windows XP Pro SP3 Ubuntu 11.04 via Virtual Box RS Enterprise 2012r1.1 Programming Tutorials & Free Projects: http://www.JasonTheAdams.com "Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- 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]
