PDA

View Full Version : how to show image name ???



santral
12-09-2007, 04:21 AM
hi,
how can I show image names in a label or text..

for example : mypicture.jpg I want to take "mypicture" and show it in an area...so when we selected any image ,image name will be appear...

it wont be object name, will be images own names...
please help...
I searched but couldnt find in forum...

holtgrewe
12-09-2007, 09:05 AM
santral -

This code gets the properties of the object "Image1" and stores them in a table called iProps. The entire path and name of the image will be returned. If you just want the name, you will have to use a string function to extact it.


iProps = Image.GetProperties("Image1")
Dialog.Message("Image Name: ", ""..iProps.ImageFile)

This should get you started. HTH

santral
12-09-2007, 09:52 AM
thanks for reply.
can you give me an exmaple of sitring function to dont show entire path...
I couldnt take only imagename from "/Autoplay/Images/imagename.jpg"
could you help pls !!!:huh

DaSoulRed
12-09-2007, 09:59 AM
for the Avatars i think u are realated some how are you family or something.
do work at same place.

well any how how i wish you well :wow

holtgrewe
12-09-2007, 10:27 AM
Santral
Here's something you may try:


iProps = Image.GetProperties("Image1")
title = String.Right(iProps.ImageFile, (String.Length(iProps.ImageFile) - String.ReverseFind(iProps.ImageFile, "\\", true)));
Dialog.Message("Image Name: ", ""..title)

hth

santral
12-09-2007, 11:02 AM
really thanks holtgrewe
it helped me...
and the final code :
dynamic label for each image ;)


function imgname ()
iProps = Image.GetProperties("Image1")
title = String.Right(iProps.ImageFile, (String.Length(iProps.ImageFile) - String.ReverseFind(iProps.ImageFile, "\\", true)));
Label.SetText("Label1",""..title);
end

thanks again holtgrewe ....

santral
12-09-2007, 02:59 PM
and I wrote a new one
in previous one text was image.jpg
now the new one without .jpg ->


function isim ()
iProps = Image.GetProperties("Image1")
uzunluk = String.Length(iProps.ImageFile) - String.ReverseFind(iProps.ImageFile, "\\", true);
title = String.Right(iProps.ImageFile, uzunluk );
tek = String.Left(""..title ,uzunluk - 4 );
Label.SetText("Label1",""..tek);
end

Is it good code, holtgrewe ? did I learn this work!

santral
12-10-2007, 02:53 PM
heeyyy....
when I build it ,names changed and become ap20,ap30,......
how can we solve this problem ???

holtgrewe
12-10-2007, 07:11 PM
The code appears to be okay; however the function will only work with "Image1" and "Label1" the way it is coded. If you want this to work with multiple Images, you will need to pass the Object names in the function.

Check the help file on how to create functions:

Here's one way - maybe not the most efficient...


function isim (img, lbl)
iProps = Image.GetProperties(""..img)
uzunluk = String.Length(iProps.ImageFile) - String.ReverseFind(iProps.ImageFile, "\\", true);
title = String.Right(iProps.ImageFile, uzunluk );
tek = String.Left(""..title ,uzunluk - 4 );
Label.SetText(""..lbl,""..tek);
end


Then when calling the function use:

function("Image1", "Label1")
-- etc.
function("Image6", "Label6")
--etc.


I have not tested this, so you may have to tweak it some to get it to work for you.

HTH

santral
12-11-2007, 05:53 AM
thanks holtgrewe...you r very helpful..
I could solve this problem. I made a LargeImage and all images goes here when clicked,so I only used LargeImage in code...and one function that you give is enough for me,and worked quite good....

BUT the main problem becomes after building..... There are .dat file names instead of image names :huh
for example before build ; name = mypicture1 or mypicture2 ...etc
after build ; name = ap45 or ap46 .....etc

how to solve this problem ???

Mina
12-11-2007, 09:07 AM
I suggest you do not include your pictures in the project when publishing.
Instead, keep them in the source folder so you could load them using


-- example
Image.Load("Image1", "AutoPlay\\Images\\indigorose.png");


If you do not want users to be able to edit/open the pictures i suggest you create a .zip archive and add all your pictures inside.
If so, you could use something like



--[[ lets assume your password for the zip file "imgs.zip" is "mypassword" ]]--
zipfile = (_SourceFolder.."\\imgs.zip") --where the file that has all the pictures in
Zip.Extract(zipfile, {"*.*"}, _TempFolder, true, true, "mypassword", ZIP_OVERWRITE_ALWAYS, nil);