[code] dim pPictureIn As Picture
dim iWidthIn As Integer
dim iHeightIn As Integer
dim pPictureOut As Picture
If Obj.PictureAvailable then
pPictureIn = obj.Picture
iWidthIn = pPictureIn.Width
iHeightIn = pPictureIn.Height
pPictureOut = me.DrawPicture ( pPictureIn as Picture, 0, 0, 100, 100, 0, 0, iWidthIn, iHeightIn)
Me.Image=Obj.Picture
elseif Obj.FolderItemAvailable then
Me.Image=Picture.Open(obj.FolderItem)
End if
[/code]
The above code is in the DropObject event of an ImageWell. I want to drag/drop a jpeg of unknown size into the ImageWell and have it resized to 100x100 pixels. Could someone please tell me where my error is - I get a syntax error on the pPictureOut=me.drawpicture line
In your code, “me” is the imagewell. As such, it has no DrawPicture method. What you need is a Graphics object. To get that you must first create pPictureOut and then acquire its Graphics property.
//CODE FROM DROPOBJECT OF IMAGEWELL:
dim pPictureIn As Picture
dim iWidthIn As Integer
dim iHeightIn As Integer
dim pPictureOut As Picture
If Obj.PictureAvailable then
pPictureIn = obj.Picture
elseif Obj.FolderItemAvailable then
pPictureIn = Picture.Open(obj.FolderItem)
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
me.Width = 100
me.Height = 100
//CODE FROM ADDIMAGE BUTTON ACTION EVENT
dim pPictureIn As Picture
dim iWidthIn As Integer
dim iHeightIn As Integer
dim pPictureOut As Picture
pPictureIn = PlunkettPhoto
iWidthIn = pPictureIn.Width
iHeightIn = pPictureIn.Height
pPictureOut = New Picture(100, 100)
pPictureOut.Graphics.DrawPicture(pPictureIn, 0, 0, 100, 100, 0, 0, iWidthIn, iHeightIn)
iwImage.Image = pPictureOut
I place the image I have been using to test into the resources of the project (named plunkettphoto). If I use the AddImage button to place the resource file into the imagewell it works perfectly - image is scaled and displayed correctly.
The exact same code in the DropObject event of the ImageWell (when the original jpeg from the desktop is dragged to the same ImageWell) doesn’t scale the image - or at least it doesn’t display the scaled image after the action is complete.
As I use the debugger to step through the DropObject event, everything appears to work correctly. pPictureOut is scaled properly and when the contents of the picture of pPictureOut is examined in the debugger it is scaled properly and not cropped. But when the event completes the image displayed in the ImageWell is original size and cropped.
did you solve the problem? I have the same “problem”. I don’t fully understand what happens on drag & drop. I think I miss an event like “paint” that does reset my picture… Is there anybody with a helping hand? Thanks a lot!