problem with imagewell drop object

this code is in the Open event handler of the ImageWell

Me.AcceptPictureDrop me.AcceptFileDrop("image/jpeg")

this code is in the DropObject event handler of the ImageWell

[code] dim pPictureIn As Picture
dim iWidthIn As Integer
dim iHeightIn As Integer
dim pPictureOut As Picture

If Obj.PictureAvailable then
pPictureIn = obj.Picture
End if

iWidthIn = pPictureIn.Width
iHeightIn = pPictureIn.Height
pPictureOut = New Picture(100, 100)
pPictureOut.Graphics.DrawPicture(pPictureIn, 0, 0, 100, 100, 0, 0, iWidthIn, iHeightIn)
me.Image = pPictureOut

Return[/code]

the FileTypes editor has 1 filetype set from the drop down menu for a jpg image.

the ImageWell is 100x100 and the file I am dropping on it is 160x160. When I drop the file (from the desktop) on the ImageWell I get the fatal error and Xojo IDE, not just the debug app, shuts down.

I have opened the jpg with both Preview and Photoshop and it is not corrupted or problematic in any way.

This application has encountered a fatal problem and must be shut down. Please tell us more about this problem. An error report has been prepared which will help us improve the product. Would you like to launch Feedback and report the problem now?

Can anyone offer any advice?

thanks so much

for one you are making a dangerous assumption in your drop event.
you are assuming that you will end up with a valid pPictureIn
But if you are droping a FILE (jpg etc) then YOU DO NOT HAVE A PICTURE… until you load it from the file (which I do not see here)

That being said… you then continue assuming you have a pPicturein… if it is NIL then DRAWPICTURE will FAIL

Agree with all you said Dave. But I am experimenting with how to do this. I have a blank window with nothing but the ImageWell. When it gets to an actual app I will put in all the safeguards. but for this I know I have a good picture and there is no extraneous code going on. I placed a trace in the window open event and when I drag and drop the picture - the trace shows the first dim statement in the drop event and then the error pops up. I can’t event track it to a statement in the code…

thanks

Ok, I had a brain fart - I’m actually dropping a file that is a picture, not an image. I added the folderitem to the code as:

If Obj.PictureAvailable then pPictureIn = obj.Picture elseif Obj.FolderItemAvailable then pPictureIn = Picture.Open(obj.FolderItem) End if
with the same results. The code freezes on the Dim pPictureIn first line in the DropObject event…

This is getting weird. I decided to delete the filetype set from the drop down menu and add my own as image/jpg. tried 3 test. the 3rd time it did the same as above but the first 2 times it dropped the image but gave the error when I quit the app. The trace was on the quit statement in the quit event for the app.

what’s going on?

I just duplicated the exact code you have above…

And hate to say this… but it worked… did not freeze or bomb… but also did NOT rescale the picture as I would have expected.

I have no doubt that it worked. I have something else going on. Let delete everything and start clean. Something is hinkey.

try replacing your imagewell with a canvas… at least for testing and see if things change