New topic: Basic Question about Resized Picture to Canvas Back [Solved]
<http://forums.realsoftware.com/viewtopic.php?t=29739> Page 1 of 1 [ 6 posts ] Previous topic | Next topic Author Message rbasic20091005153 Post subject: Basic Question about Resized Picture to Canvas Back [Solved]Posted: Tue Aug 25, 2009 7:39 pm Joined: Sat Apr 04, 2009 5:10 pm Posts: 269 Hola, I know there are many posts for this subject. I've read quite a lot of them. And I guess I don't quite understand how to use Graphics.DrawPicture. What I want to do is to rescale the picture (MyPictItem.OpenAsPicture/MyPict) to 64 x 64 and then send it to Canvas(Canvas4) Backdrop. Code:If Listbox3.ListIndex >= 0 Then // No selection error prevention Dim MyPictItem As FolderItem MyPictItem=GetFolderItem(Listbox3.Cell(Listbox3.ListIndex,1),FolderItem.PathTypeAbsolute) If MyPictItem.OpenAsPicture<>Nil Then Dim MyPict,p As Picture p=NewPicture(64,64,32) MyPict=MyPictItem.OpenAsPicture p.Graphics.DrawPicture MyPict,0,0,64,64,0,0,0,0 Canvas4.Backdrop=p Else Exit Sub End if Exit Sub End if What am I doing wrong? I'm sorry for asking such a basic question. Thank you for your advice. Tom _________________ Mac OS X 10.5.6/REALBasic 2008 R4 I say 'no' to MBS plug-ins. I boycott them. Last edited by rbasic20091005153 on Tue Aug 25, 2009 8:27 pm, edited 1 time in total. Top serd83 Post subject: Re: Basic Question about Resized Picture to Canvas BackdropPosted: Tue Aug 25, 2009 8:04 pm Joined: Thu Feb 22, 2007 7:08 pm Posts: 659 Something you must make wrong. For test run this code in a button: Code:dim f as folderitem = getopenfolderItem("") dim p as picture = f.openaspicture canvas4.graphics.drawpicture p, 0, 0, 64, 64, 0, 0, 64, 64 Back to your orginal code: Code:Dim MyPictItem As FolderItem MyPictItem=GetOpenFolderItem("") If MyPictItem.OpenAsPicture<>Nil Then Dim MyPict,p As Picture p=NewPicture(64,64,32) MyPict=MyPictItem.OpenAsPicture p.Graphics.DrawPicture MyPict,0,0,64,64,0,0,64,64 Canvas4.Backdrop=p End if Last edited by serd83 on Tue Aug 25, 2009 8:23 pm, edited 1 time in total. Top rbasic20091005153 Post subject: Re: Basic Question about Resized Picture to Canvas BackdropPosted: Tue Aug 25, 2009 8:17 pm Joined: Sat Apr 04, 2009 5:10 pm Posts: 269 Code:If Listbox3.ListIndex >= 0 Then // No selection error prevention Dim MyPictItem As FolderItem MyPictItem=GetFolderItem(Listbox3.Cell(Listbox3.ListIndex,1),FolderItem.PathTypeAbsolute) If MyPictItem.OpenAsPicture<>Nil Then dim p as picture p = MyPictItem.OpenAsPicture canvas4.graphics.drawpicture p, 0, 0, 64, 64, 0, 0, 64, 64 Else Exit Sub End if Exit Sub End if Thank you very much for your prompt response, serd83. With your code, the backdrop picture will actually appear without its being re-scaled. _________________ Mac OS X 10.5.6/REALBasic 2008 R4 I say 'no' to MBS plug-ins. I boycott them. Top rbasic20091005153 Post subject: Re: Basic Question about Resized Picture to Canvas BackdropPosted: Tue Aug 25, 2009 8:19 pm Joined: Sat Apr 04, 2009 5:10 pm Posts: 269 serd83 wrote:Change the line in your code: Code:p.Graphics.DrawPicture MyPict,0,0,64,64,0,0,0,0 to Code:p.Graphics.DrawPicture MyPict,0,0,64,64,0,0,64,64 Edit: Your code was ok until the line above, I test it now. You forgot to use the last 2 fields which are 0, 0. Change it to 64, 64 and it work's correct. Thanks. No re-scaling again... _________________ Mac OS X 10.5.6/REALBasic 2008 R4 I say 'no' to MBS plug-ins. I boycott them. Top rbasic20091005153 Post subject: Re: Basic Question about Resized Picture to Canvas BackdropPosted: Tue Aug 25, 2009 8:25 pm Joined: Sat Apr 04, 2009 5:10 pm Posts: 269 I got it. Code:p.Graphics.DrawPicture MyPict,0,0,64,64,0,0,MyPict.Width,MyPict.Height Without your help, I would have overlooked my silly mistake. Thanks a lot, serd83. Tom _________________ Mac OS X 10.5.6/REALBasic 2008 R4 I say 'no' to MBS plug-ins. I boycott them. Top serd83 Post subject: Re: Basic Question about Resized Picture to Canvas BackdropPosted: Tue Aug 25, 2009 8:26 pm Joined: Thu Feb 22, 2007 7:08 pm Posts: 659 Sorry, I use the Back button with the webbrowser and edit the code above again instead create a new answer. All the code above I post work's correct, which I test also now. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 6 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]
