I am creating a set of images and storing them in an imagelist. Everything worked OK until I tried to resize each image (using DrawerEx) before adding it to the imagelist. If I do that the images are created and resized correctly but if I look at the contents of the imagelist all the images are the same - they are all the last image to be added. I have done checks such as saving each image as as bmp as it is created, before and after resizing and the last imagelist item added. All is correct. But if I write out ALL the images in the imagelist each time I add one, then I see that in each iteration, all the images are the same as the last one added. It seems that the imagelist image is created as a reference to the 'current' source image, not the source image itself!
The strange thing is this only happens if I add a resize step. Just creating and adding the source image works fine, all the imagelist images remain unique individuals!
the code I am using is
rectdest & rectsrc object RectangleEx
sourcebmp.New2(w,h) 'object bitmap
outputbmp.New2(w,h) 'object bitmap
Createdimg.New1 'object ImageClass
resizebmp.New2(outputbmp.Value) 'object DrawerEx
(loop)
(make the image in Createdimg.image)
sourcebmp.Value = CreatedImg.Image
resizebmp.DrawImage(sourcebmp.Value,rectsrc.Value,rectdest.Value,False)
imagelist1.Add(outputbmp.Value)
(end loop)
This does work:
(loop)
(make the image in Createdimg.image)
sourcebmp.Value = CreatedImg.Image
imagelist1.Add(sourcebmp.Value)
(end loop)
I'm afraid posting the whole program is not really feasible, it generates the images from files I can't distribute. Cutting out the problem bit will also be complex.
The strange thing is this only happens if I add a resize step. Just creating and adding the source image works fine, all the imagelist images remain unique individuals!
the code I am using is
rectdest & rectsrc object RectangleEx
sourcebmp.New2(w,h) 'object bitmap
outputbmp.New2(w,h) 'object bitmap
Createdimg.New1 'object ImageClass
resizebmp.New2(outputbmp.Value) 'object DrawerEx
(loop)
(make the image in Createdimg.image)
sourcebmp.Value = CreatedImg.Image
resizebmp.DrawImage(sourcebmp.Value,rectsrc.Value,rectdest.Value,False)
imagelist1.Add(outputbmp.Value)
(end loop)
This does work:
(loop)
(make the image in Createdimg.image)
sourcebmp.Value = CreatedImg.Image
imagelist1.Add(sourcebmp.Value)
(end loop)
I'm afraid posting the whole program is not really feasible, it generates the images from files I can't distribute. Cutting out the problem bit will also be complex.