Click to See Complete Forum and Search --> : JPEG error #41,return pics from database
Leite33
September 23rd, 2006, 07:45 AM
Hi. I saved pictures in database by using blob method. So when i try to get the pics back i get this error:JPEG error #41.. Why; I get this error even i choose bmb pic to return or other files like tif picture....
What is wrong; the code is correct for saving pictures and to get them but i have this error. I inlude <JPEG.hpp> library but still i get this error
greg_dolley
September 23rd, 2006, 09:29 PM
Leite33,
Can you post your code?
Greg Dolley
Leite33
September 24th, 2006, 12:35 AM
Yes. The code for save pictures with blob works and the pictures are in database so the code for retrieve pics is:
Image1->Picture=NULL;
TStream *Blob;
Blob=ADOTable1->CreateBlobStream(ADOTable1->FieldByName("File"),bmRead);
TJPEGImage *jp=new TJPEGImage;
jp->LoadFromStream(Blob);
Image1->Picture->Assign(jp);
Nothing special but have to work..... Why it doesnt??
greg_dolley
September 25th, 2006, 05:18 AM
Leite,
I don't see anything wrong with your code. Since you're using a third party library to do image manipulation, I would contact their tech support. Sounds like a bug in their library.
There's one thing you can do to see if there's something wrong in the library: get a hex editor (or any binary editor, I recommend: http://www.sweetscape.com/010editor/), write the contents of the retrieved blob to a new binary file, and then compare the binary data of the original picture to the binary data of your newly created file. If they are not exactly the same, then the library must do something wrong (assuming the database itself isn't corrupting the blob data).
Greg Dolley
Leite33
September 25th, 2006, 06:55 AM
Good thought i was thinking the same. I red one day in Delphi same problem. So what he did:
1. Saved the records in file ADOTable1->SaVeToFile("c:\\.dat")
then he made a search fuction to see where the adresses are for jpeg or else formats. So when it find jpeg the pic come back.. Something like that... But i think its diffcult to do that in C++.
About the library.. You mean <jpeg.hpp> ok lets say that work but if you want to return tif file or png...
greg_dolley
September 26th, 2006, 02:23 PM
Good thought i was thinking the same. I red one day in Delphi same problem. So what he did:
1. Saved the records in file ADOTable1->SaVeToFile("c:\\.dat")
then he made a search fuction to see where the adresses are for jpeg or else formats. So when it find jpeg the pic come back.. Something like that... But i think its diffcult to do that in C++.
About the library.. You mean <jpeg.hpp> ok lets say that work but if you want to return tif file or png...
1) The jpeg library doesn't have a save to file function???
You don't need to do anything with addresses, I'm saying just save the picture to a file, then open that file with a binary editor. The editor I mentioned has a "compare files" option, so you can open the original bitmap and the file you saved to see if there are any differences.
If you want to do the same thing with tif or png, you'll probably have to get a different library because it sounds like the one you're using only supports jpeg. Of course, you can always crack open a book about image formats and write your own save functions. ;)
Greg Dolley
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.