PDA

View Full Version : Planner, Diary, Photos


JDog37
12-25-2008, 06:21 AM
I used 3 diffrent examples for a planner I made for my wife, (Thanks to all of you) and on the 3rd page I wanted for her to be able to save her favorite photos. Well the only problem I can find is it will let me save them but it will only allow like 3 or 4 then it wont add anymore????:huh

Page: On show -
db = SQLite.Open("Autoplay\\docs\\images.db")

if db then

tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")

else
Dialog.Message("Error", _tblErrorMessages[Application.GetLastError()])
end

if tblQ then

ListBox.DeleteItem("ListBox1", -1)

for n=1, tblQ.Rows do

ListBox.AddItem("ListBox1", tblQ.Data[n]["Image_Title"], n)

end

end

The list box: On select - Selected = ListBox.GetSelected("ListBox1")

if Selected then

x = String.ToNumber(ListBox.GetItemData("ListBox1", Selected[1]))
Image_Data = tblQ.Data[x]["Image"]
Image_ID = tblQ.Data[x]["ImageID"]

local Image_File = _TempFolder.."\\IMG.jpg"

Crypto.Base64DecodeFromString(Image_Data, Image_File)

Image.Load("Image1", Image_File)

Image.SetVisible("Image1", true)

Button.SetEnabled("Button2", true)

end

The add photo btn: On click -
local Image_File = Dialog.FileBrowse(true, "Select Image File", "", "Jpeg Files (*.jpg)|*.jpg|" , "", "")

if Image_File ~= "CANCEL" then

encoded_image = Crypto.Base64EncodeToString(Image_File[1], 0);

-- Check to see if an error occurred using the Crypto.Base64EncodeToString action.
error = Application.GetLastError();
if (error ~=0) then
result = Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
return
end

if encoded_image == "" then
Dialog.Message("Sorry", "Could not encode image file", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
return
end

Image_Title = Dialog.Input("Image Title", "Please enter a title for this image", "My Cool Image", MB_ICONQUESTION)

if Image_Title == "CANCEL" or Image_Title == "" then
Image_Title = "My Cool Image"
end

SQLite.Query(db, "Insert into Images Values(Null, \"" .. encoded_image .. "\", '" .. Image_Title .. "')")

tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")

if tblQ then

ListBox.DeleteItem("ListBox1", -1)
for n=1, tblQ.Rows do

ListBox.AddItem("ListBox1", tblQ.Data[n]["Image_Title"], n)
end

end

end

Clear btn: On click -
if Selected then

SQLite.Query(db, "DELETE FROM Images WHERE ImageID="..Image_ID)

tblQ = SQLite.QueryToTable(db, "SELECT * FROM Images")

if tblQ then

ListBox.DeleteItem("ListBox1", -1)
for r=1, tblQ.Rows do

ListBox.AddItem("ListBox1", tblQ.Data[r]["Image_Title"], r)
Progress.SetCurrentPos("Progress1", r)
end

end

Button.SetEnabled("Button2", false)

Image.SetVisible("Image1", false)

end

I cant figure it out, because I'm not a programing wiz, but I like to tinker around.. With that said, I don't know how to debunk it.

Can anyone please help me??

All I want is to be able to add as many photos as I want..! :rolleyes

Thanks,
Joe

Ps. The .apz is like 4mb, so I can't upload it unfortunately...

JDog37
12-25-2008, 11:23 AM
Ok, I tried changing around code but it's still not any better, so I undone everything and now I'm ready to throw the PC out the window!!!!! Argg! :eek:

I know, its Christmas.. ;) BUT, I know there are allot of you talented people that can't put down a mouse, LMAO.....:D

Anyone -

Dermot
12-25-2008, 04:02 PM
It looks like you are using an example I posted for storing images in an SQLite database. What happens if you use my example on its own? Are you able to insert as many photos as you like? I just tested the example and had no problems.

JDog37
12-25-2008, 05:35 PM
Hey Dermot, Yes I tried just the example you created and I get to 4 photo's and on the 5th it lets me pick what I want but after naming it, it dos'nt show up in the listbox!?

Is it poss that I had a bad download? I normally don't get a bad download from the forum tho- But other than that, I love what you created. You have a great brain! Lol..

All I did was copy/paste the code from the project and put it on a page in mine with all the other code but I can't get yours past 4 either.

Any ideas??

JDog37
12-25-2008, 06:06 PM
Here is Dermot example as I got it..

go here: http://www.joesphotoshop.com

I hope you don't mind the re-post? :rolleyes

Thanks,
Joe

Dermot
12-25-2008, 09:15 PM
Works perfectly for me, must be something on your end.

JDog37
12-25-2008, 11:07 PM
As far as?? What I'm using for a PC, or? My Q: is how are all the other .apz's work and only his one dont? I'm not doubting you at all, Is there something I got to download to check? Or am I missing a dll? Is there another apz that you know of that is of the same lines as this one? :huh

Sorry for all the questions. Just trying to make it work...

Thanks Dermot! :yes

Joe

Dermot
12-25-2008, 11:16 PM
I have no idea. All I know is it works for me. I don't know how many have used or tried that example, but no one has reported any problems as far as I know.

There are no dlls or anything like that.

JDog37
12-26-2008, 08:48 AM
I think It might be my photos are to big 3888 x 2592. I got more to work at a smaller size. I don't want a limit tho- Is there a way to resize the photo to fit when it is showed?

Thanks Dermot,
Joe


Idea: I was thinking, Maybe even an export feature could be added? to download it to the desktop..

Dermot
12-26-2008, 09:18 AM
You will run in to problems with this method if the images are very large. When the image is encoded, the SQL insert statement will be too long so the insert will fail. You will need to resize the photos before adding them to the database.

JDog37
12-26-2008, 09:46 AM
Ok, i will do that. Any sug size?

Thank you again Dermot, :yes I really do appreciate your help. If you'd like I will post the project when I'm done.

Thnks again,
Joe

JDog37
12-27-2008, 01:01 AM
with this method if the images are very large.

Any other method? Is there a way to have the project scale it down on entry? :wow

Dermot
12-27-2008, 01:16 AM
You could just save the paths to the images in the db instead of saving the actual images. The downside if this is that the app is not portable and if you move the images, the paths will be broken.

You could use this to resize the images on the fly as you are inserting them. http://www.indigorose.com/forums/showthread.php?t=25782 Don't ask me for an example, I don't have the time. The Lua-GD docs explains the resize function.

1232310
12-27-2008, 10:50 AM
thanks for all

JDog37
12-27-2008, 04:19 PM
I'll go look at it, Thanks again Dermot! :yes

RizlaUK
12-28-2008, 08:27 AM
im sure i posted a small dll to resize/reformat images but i cant seem to find it, easy enough to recreate tho, i'll do it later

JDog37
12-28-2008, 06:20 PM
Thank you for the help!! I know your ALL busy with the holidays. I appreciate it.

The one apz I did find was good but it only croped to a small size. Im looking for one to crop whatever size big or small. I'll keep searching tho- :yes

Happy holidays!
Joe