[solved] unknown picture format

The stable tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.
Post Reply
kidjake28
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 27.04.2013, 16:56

[solved] unknown picture format

Post by kidjake28 »

I am using zeosib 7.0.3 with Delphi 2010.


I have a sqlite3 database which contains a picture blob field. When I try to attach the DB to a table and then to a data set the dbaware picture vcl Picshow delphiarea.com reports back an error unknown picture format.

This does work with the sivak3 sqlite3 dbase vcl tools.

What could be the problem?
kidjake28
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 27.04.2013, 16:56

Post by kidjake28 »

Anyone?

Please.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Post by marsupilami »

Hello kidjake28,

how do you put the pictures into the database and what kind of pictures are in it (jpeg, png, ...)?
If you say, it works for "sivak3 sqlite3 dbase vcl tools" then this seems to mean that it works for DBase which is a whole different story to SQLite?
Best regards,

Jan
kidjake28
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 27.04.2013, 16:56

Post by kidjake28 »

Do you have an example of how I should import the pictures....I'm finding that if I create a loop such as below, the imported data gets all mixed up. Meaning the fields gets imported into the wrong fields. I know this has nothing to do with blob fields but I'm thinking that the way I'm importing the data is incorrect. This does work for mssql. What am I doing wrong?

MainDM.adoweather.edit;
For i = 1 to 10
begin
MainDM.adoweather.fieldbyname('current').asinteger = variable1
MainDM.adoweather.fieldbyname('mon').asinteger= variable2
MainDM.adoweather.fieldbyname('tue').asinteger=variable3
end;
MainDM.adoweather.post;
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

kidjake28,

can you attach a create script? Or is it possible you did upgrade from 6.6 to 7.0.3? Here i know about differences accordingly reading/writing BLOB's.

Do you use cached updates? Some more informations would be helpful to support you.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
kidjake28
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 27.04.2013, 16:56

Post by kidjake28 »

Here it is...forgive me if bad code...I'm a beginner.

Code: Select all

if (xmlLUD > MainDM.adoAgents.FieldByName('lastupdated').AsDateTime) and (result = true) then
            begin
              writeToLog(3, 'Update agents record');
              MainDM.adoAgents.edit;
            end
          else if result = false then
            MainDM.adoAgents.Insert;

          if MainDM.adoAgents.State in [dsEdit, dsInsert] then
            begin
              MainDM.adoAgents.FieldByName('agentid').AsInteger := xmlID;
              MainDM.adoAgents.FieldByName('name').AsString := httpdecode
                (Anode.Items[i].Properties.ItemNamed['name'].Value);
              MainDM.adoAgents.FieldByName('phone').AsString := httpdecode
                (Anode.Items[i].Properties.ItemNamed['phone'].Value);
              MainDM.adoAgents.FieldByName('email').AsString := httpdecode
                (Anode.Items[i].Properties.ItemNamed['email'].Value);
              MainDM.adoAgents.FieldByName('title').AsString := Anode.Items[i].Properties.ItemNamed['title'].Value;
              MainDM.adoAgents.FieldByName('memberid').AsString := Anode.Items[i].Properties.ItemNamed['memberid']
                .Value;
              MainDM.adoAgents.FieldByName('lastupdated').AsString := Anode.Items[i].Properties.ItemNamed['lud'].Value;

              if urlexists(Anode.Items[i].Properties.ItemNamed['pic'].Value) then
                begin
                  myStream := Tmemorystream.Create;
                  httpClient.url := Anode.Items[i].Properties.ItemNamed['pic'].Value;
                  httpClient.RcvdStream := myStream;
                  httpClient.Get;
                  tblobfield(MainDM.adoAgents.FieldByName('picture')).LoadFromStream(myStream);
                  myStream.Free;
                end
              else
                tblobfield(MainDM.adoAgents.FieldByName('picture')).LoadFromFile('agents\noagent.jpg');

              MainDM.adoAgents.Post;
            end;
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

kidjake28,

sure your load a binary stream from your URL? It might be possible you receive a Base64 encoded string. The Indy components have a component for convertation.

On the other hand: I can't see "wrong" code right now. The way you read the stream is right. Check if myStream.Position is 0. Did you ever check the Memory of the received string? Excample:

Code: Select all

var s: AnsiString;
begin
  MyStream.Position := 0;
  SetLength(s, myStream.Size);
  System.move(PansiChar(MyStream.Memory)^, PAnsiChar(s)^, MyStream.Size);
  ..
  now you can debug the string and check Size and header.
end;
before going on, please check my suggestions. I can't remember equal issues latly.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
kidjake28
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 27.04.2013, 16:56

Post by kidjake28 »

The url stream points to a jpeg image file.

I know this works because if I change the components to SIVAK sqlite3 it works fine to some extent. I believe I have another problem with concurrency but I'll look into that a bit more.

In the mean time if I use zeos, it doesn't seem to store the image properly.

As far as reading the blob, I use tdbpicshow component which is connected to the database (no code required).

As mentioned before it works with mssql as well as sivak, just not with zeos. What am I doing wrong?
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

kidjake28,

sure the field is declared a BLOB type?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
kidjake28
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 27.04.2013, 16:56

Post by kidjake28 »

I think I know what the problem is....I used a program to convert a database from MSSQL to SQLITE. It seem to have converted properly.

When I used sqliteexpert to view the data it shows the pics but as I mentioned when I tried to view them using my delphi app, I would get an unknown picture format.

So I deleted the pics and re-downloaded them from the site. The pics seems to be working.

I think the problem is solved. However, I am having another show stopper and rather then continuing it in this thread I will create a new topic.

I'm really really trying to switch over to sqlite so if someone would be kind enough just lik Egon (or even Egon) to help me out I would greatly appreciate it.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

kidjake28,

this is strange! We use exacly the algorythm descibed from Sqlite. Also do we use a GetLob api call to read the lobs. The results are exact. So i guess your second programm has it's own way to read and write the BLob's...
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply