imagebutton error

kolbe

Active Member
Licensed User
Longtime User
Hello all,

The following code gives me an out of memory error IDE error. The error is on the last line when I assign the imagebutton1.image to bin.retrieveimage. There are several images embedded in data.dat. If I change imagebutton1.image to image1.image all is fine. Using version 6.05.

B4X:
FileOpen(c1,"data.dat",cRandom)
bin.New1(c1,true)
image1.Image=bin.RetrieveImage
imagebutton1.Image=bin.RetrieveImage
FileClose(c1)

The error is the following:

Consultez la fin de ce message pour plus de détails sur l'appel du débogage
juste-à-temps (JIT) à la place de cette boîte de dialogue.

************** Texte de l'exception **************
System.OutOfMemoryException: Mémoire insuffisante.
à System.Drawing.Graphics.CheckErrorStatus(Int32 status)
à System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
à System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
à System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
à Dbasic.EnhancedControls.CEnhancedImageButton.OnPaint(PaintEventArgs e)
à System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
à System.Windows.Forms.Control.WmPaint(Message& m)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Any ideas?

Thanks
 

skipper

Member
Licensed User
I never used RetrieveImage, but I suppose that in order to embed several images into the .dat file you used the EmbedFile command.
Have you alredy tried the Retrievefile?
Have you tried to switch the "Image" instruction with the "imageButton" instruction just to see if the program behaviour changes?
It seems to me, but I'm not an expert, that RetrieveImage could raise the error for 2 reason
1) he starts reading at an offset of the .dat file where there are no information about the image file (something has been already read by the image instruction and the pointer has been moved)
2) he can read only an image (there are no parameters to specify what and where to read inside the .dat)
But as I said I could be totally wrong..
Mimmo
 

kolbe

Active Member
Licensed User
Longtime User
skipper,

I did use the embedfile command to create the data.dat. All works fine if I use image1.image or form1.image with bin.retrieveimage, so I know data.dat is OK. It is only when I use imagebutton1.image that I get this error. My understanding is that a bitmap is passed by bin.retrieveimage and then should work for all object.image. Imagebutton1.image="file.gif" works as well. I think it might be a bug of some kind.

thanks
 

klaus

Expert
Licensed User
Longtime User
Bonjour kolbe

I had the same kind of problem.

Your ImageButton1 is probably set to transparent, in this case you get an error.
If you set transparent to false and after loading the image you set it to transparent it works.

Look under

http://www.b4x.com/forum/showthread.php?t=1766

Meilleures salutations
Klaus
Switzerland
 
Top