I know this is really easy, but for some reason I’m … missing it.
I want to scale an image AFTER it is selected with a folderItem.ShowOpenFileDialog.
Var f As FolderItem = FolderItem.ShowOpenFileDialog("")
var f2 as FolderItem = FolderItem.ShowOpenFileDialog("")
If f <> Nil and f2 <> Nil Then
app.pic1 = Picture.Open(f)
app.pic2 = Picture.Open(f2)
Canvas1.Backdrop = app.pic1
Canvas2.Backdrop = app.pic2
// Assuming you've loaded or created your pictures...
If areSimilar(app.pic1, app.pic2, 10) Then
MessageBox "Same"
else
MessageBox "Different"
End If
end if
I get the image fine, and have verified it so stepping through.
Normally, under the paint event of a canvas I can use
Decouple the logic from the UI. Pictures don’t need a Canvas to operate.
// Nil check and be a little more helpful
if f = nil or f2 = nil then
MessageBox("One of the FolderItems was nil")
return
end
// Do not use global properties!
var picLocal as Picture = Picture.Open(f)
var picCompare as Picture = Picture.Open(f2)
// Find out if these are good
if areSimilar(picLocal, picCompare, 10) then
MessageBox("Same")
else
MessageBox("Different")
end
You’ll want to do something like this to scale the image into a new picture.
dim inputPic as Picture = Picture.Open(f)
dim destWidth as integer = 100
dim destHeight as integer = 100
dim scaledPic as new Picture(destWidth,destHeight)
scaledPic.Graphics.DrawPicture(inputPic, 0, 0, destWidth, destHeight, 0, 0, inputPic.Width, inputPic.Height)
I learned Xojo downloading source code to see how they were made. You can go on my website and download the app “GalleryCaptShot” . Once launch, select the menu “Capture - Bring first” and then the menu “Capture - Choose file”. (On Mac you can make a screencapture but not under Windows).
If you want to see to see the code, on my website select the menu “Developper - Xojo source” then download the “GalleryCaptShot” and “Zx_External” source. Unzip and open “GalleryCaptShot 1.5.0.xojo_binary_project”.
Sure I’m not the best teacher to show Xojo code, but it may help you for the first steps.