HELP!!! Image Imbedding and retrieval

XerVision

Member
Licensed User
I embedded my images (as .jpg then as .bmp) in one file and used retrieveimg to open the file. It opened the file into an imagelist- however only my first form come up with the right image.. All my other forms have big red x's on them.:(
 

XerVision

Member
Licensed User
Sure- I am now finding a quirk with the system. It seems I must load up the imagelist according to where it is in the memory per Sub-- is that right?

The following is how I am attempting to retrieve the data.
I have four forms that I am putting the images on.. Form1 ...Form4
I notice that if an image does not display - it corrupts that image and it cannot then be displayed again in the entire program:sign0085:

Sub App_Start
RetrieveIMG

'SPLASH SCREEN INFO
SPLASHSCREEN.Show
Timer1.Interval = 1000
Timer1.Enabled= True

SuperLocker
WOSetupData
End Sub

...


Sub RetrieveImg
'Create Directory'
'If there is an issue then the file is corrup and it need to rasie that error
FileOpen(d1,"eXeImg.dat",cRandom)
Ximg.New1(d1,true)
'GET FILES FROM LIST
for i = 0 to 4 Step +1
XiL1.Add(Ximg.RetrieveImage)
next

'PLACE IMAGES IN RESPECTIVE PLACES
'SCREENS
'SPLASHSCREEN
'

'VIEW
'WOVIEW
'
' WOBackBtn.Image =XiL1.Item(2)
' WONextBtn.Image= XiL1.Item(2)
' WOLockBtn.Image =XiL1.Item(0)

'LOCK
'Image3.Image= XiL1.Item(0)
'CARDIOLockBtn.Image= XiL1.Item(1)

'MeasLock.Image= XiL1.Item(1)
'CARDIOLOCKBTN.Image= XiL1.Item(2)



'BACK

CARDIOBackBtn.Image= XiL1.Item(2)
MeasBack.Image = XiL1.Item(2)
'WOBackBtn.Image =XiL1.Item(2)

'NEXT BTN
Nextb=3
CARDIONextBtn.Image= XiL1.Item(Nextb)
MeasNext.Image = XiL1.Item(Nextb)

'LOGO
Logo=4
AbouteLogo.Image = XiL1.Item(Logo)
CARDIOLogo.Image =XiL1.Item(Logo)
MeasLogo.Image = XiL1.Item(Logo)
Splashlogo.Image = XiL1.Item(Logo)

End Sub ' RETRIEVEIMG
 

mwaite

Member
Licensed User
I just had this happen to me yesterday too! I figured out that I needed to turn transparency off and then the image would show up.
 

XerVision

Member
Licensed User
It seems that you cannot assign an imagelist item to a imagebutton without encountering a problem. I turned all my image buttons into clickable Imagelists.
Unfortunately- that means that I lose the text on my image buttons. But it seems to be working thus far... But hopefully this sparks a "yes-- that is true" and if so, hopefully an enhancement
 

mwaite

Member
Licensed User
Erel,

Can you explain why I get a crossed out box instead of an image when I have the imagebuttons transparent in the following code:

FileOpen(c1,"img.dat",cRandom)
bin.New1(c1,true)
welcome.Image = bin.RetrieveImage ' << image
connectyes.Image = bin.RetrieveImage ' << imagebutton
connectno.Image = bin.RetrieveImage ' << imagebutton
FileClose(c1)

If I set the imagebuttons to non-transparent then they show up just fine.

I looked at your smiley example and thought perhaps you were indicating to use an imagelist instead of loading the images from the file directly to the imagebuttons, but I get the same results.
 

Erel

Administrator
Staff member
Licensed User
I see this strange behavior.
After some research I've found an article about it on the MSDN forums.
It will only happen on the desktop.
The solution is to use a copy of the image.
You could use an Image control to do it.
Add an Image control and set its Visible property to false.
Now load the image to the image control and then copy it to the transparent imagebutton:

B4X:
 Sub loadimages
    FileOpen(c1,"img.dat",cRandom)
    bin.New1(c1,true)
    welcome.Image = bin.RetrieveImage
    image2.Image = bin.RetrieveImage
    connectyes.Image = image2.Image 'Creates a new copy. 
    image2.Image = bin.RetrieveImage     
    connectno.Image = image2.Image 'Creates a new copy.
    FileClose(c1)
End Sub
 

mwaite

Member
Licensed User
OK that makes sense, and a workable solution! Thanks for looking into this!
 
Top