ImageWell DrawPicture problem

I am having a problem drawing a called picture in an image well. There following is the code. Imagewell1(0), defined on the window layout as the first in an image well set, has a default image configured and after running this code, the default image remains.

Dim f as FolderItem f=GetOpenFolderItem("") if f <> Nil then dim i as ImageWell dim j as integer dim readpic as Picture readpic = Picture.open(f) Imagewell1(0).image.graphics.drawpicture readpic, 0, 0, imageWell1(0).width, imageWell1(0).height, 0, 0, readpic.width, readpic.height

If I change the code to

Dim f as FolderItem f=GetOpenFolderItem("") if f <> Nil then dim i as ImageWell dim j as integer dim readpic as Picture readpic = Picture.open(f) //Imagewell1(0).image.graphics.drawpicture readpic, 0, 0, imageWell1(0).width, imageWell1(0).height, 0, 0, readpic.width, readpic.height imagewell1(0).image = readpic

then the image, or at least part of it, is correctly drawn into the imagewell.

Anyone got any clues? The documentation gives example of using an image well instead of a canvas so it should work.

bobj

Solved it, https://forum.xojo.com/6298-scaling-dragged-image-to-imagewell/0#p44509

The answer lay in an answer to a similar issue from sometime ago.

I needed to institute a new picture object to hold the stalled picture before assigning it to the image well object as the image well object does not have a DrawPicture method…

Amended code is

Dim f as FolderItem f=GetOpenFolderItem("") if f <> Nil then dim i as ImageWell dim j as integer dim readpic, picout as Picture readpic = Picture.open(f) picout = new Picture(imagewell1(0).width, imagewell1(0).height) picout.graphics.drawpicture readpic, 0, 0, imageWell1(0).width, imageWell1(0).height, 0, 0, readpic.width, readpic.height imagewell1(0).image = picout