Adding an image to a Field

I deleted the text I wrote earlier that explained all I’ve done to achive the task. You only have to know the current design:

I have a window set to collect three informations: Two TextFields (no problem) and a Character Logo (200 pixels tall maxi: resized down it taller).

My problem is with how to save the picture (loaded with Open or Drop from the Finder/Explorer) in the window.

At save to disk time, I naturally have to store the image into the Data Base File. I have a RecordSet with all three entries to store, but 'till now, I skipped the image part (no time to do that earlier).

The problem comes here. I tried the provided code example from Picture.GetData, but since the image was already loaded, the troubles started.

The question is:

I have the image is already stored in a Picture in a Module: from there, how can I work with the RecordSet to fill the image and save that RecordSet.

The design may be wrong: feel free to tell me that and give clues to how I can achieve this task.

Later, the user may want to print data about the character and I will use these values to do that (the image at top/left, some data will be printed at the image right, then below the image (TextField #2) and use TextField #1 for the file name. But this is a different story. I may have to end the save data in the sqlite file first.

That shouldn’t cause a problem. It doesn’t matter where you got the picture from. What errors are you getting?

Hi Tim, thank you for the help.

I came from:

// If the property is not Nil, store it If mNFF_Prefs.sdCharacterLogo <> Nil Then Character_RS.Column("Character_Logo") = mNFF_Prefs.sdCharacterLogo // Then I tried to use blob (from .CreateBlob) End If

Of course, when I comment these lines, the project compiles and run.
If I put surrounded quotes to the right part of the equal sign: it compiles and runs fine, but that is not what I want, of course.

Then I go to the SQLiteDatabase.CreateBlob example
That example loads a file from disk, needs to pass a length… I remove the BinaryStream part and replace it with a MemoryBlock, but… (next paragraph)

MB = mNFF_Prefs.sdCharacterLogo.GetData([i]format[/i])[/code] // Problem: I need to fill the [code]format
Character_RS.Column("Character_Logo") = blob // There is more than one item with this name…

I do not think all of these have to be taken into account for an answer. If I knew the answer and the question was from some person in this forum, I would write the needed code part forgetting what the op wrote / does.

I load and try to understand the SQLiteBlob example, but I failed (and… all this code to only insert an image into a SQLite Data Base ?).

The forum entry here does not help me too.

I’ve made a search on the internet, but Java code looks complex … to me.

I tried to make my home work, but either the way to store an image into a SQLIte Data Base is weird (to me) or my brain refuse to understand (or maybe I will see the light tomorrow at wake up time) ?

I found a clue here : use dbRec.PictureColumn("IMG_IMAGE") = p

I will test that right now (even if my TV Show starts…

I found that:

Character_RS.PictureColumn("Character_Logo") = mNFF_Prefs.sdCharacterLogo

I checked with my SQLIte .sqlite internal reader: the Character_Logo field holds a PNG file (the passed image comes from a gif file, but I do not care).

I think I found a solution. Thanks Tim.

Use whatever format you desire the image to be stored in. Once you get a Picture object, it no longer has a “format”. It’s just a bitmap. GetData takes that bitmap and compresses it into the format you specify and returns it as a memoryblock. You don’t have to know the format; you choose a format for how the image will be represented in the database.

Thank you Tim.

I do not correctly understand what format was doing !

For a good reason :frowning:

There is no explanation here on what they are. As usual, when there is a chance of error, I take it ! I understand the wrong solution :frowning:

Nota: it tooks me 9 hours to check why I misunderstand the docs.