Delphi Error Bitmap Image Is Not Valid
If I save it to a database and bitmap image is not valid delphi dbimage then do a load from stream it throws a 'Bitmap delphi jpeg image is not valid' error. Other bitmaps seems to work ok. However from looking delphi gif at their size, I suspect that soapbubbles is 24 or 32 bit, where as the others are 16 (i.e. GoneFishing)? I've put the appropriate delphi vector graphics snippets of code below. Any Suggestions. with qry do begin with SQL do begin Clear; Add('INSERT INTO PrintableImages(ImageName,Image) VALUES(:ImageName,:Image)'); end; qry.ParamByName('ImageName').AsString := imageName; qry.ParamByName('Image').Loadfromfile(dlgOpenFile.Filename, ftBlob); ExecSQL; end; qry.SQL.Add('SELECT * FROM PrintableImages'); qry.Open; while not qry.EOF do begin try // Associate the
Delphi Tiff
field to a TStream stream := TBlobStream.Create(TBlobField(qry.FieldByName('Image')),bmRead); //Add the image as stream thumbView.AddFromStream(stream,grBMP,qry.FieldByName('ImageName').AsString); qry.Next; finally FreeAndNil(stream); end; ... Thb.Photo.LoadFromStream(AStream, Thb.StreamFileType); .... Bmp := Graphics.TBitmap.Create; try Bmp.LoadFromStream(AStream); <<< DIES HERE Bmp.PixelFormat := pf24bit; Picture.Assign(Bmp); finally FreeAndNil(Bmp); Bryan Valencia Delphi Developer 2005-08-24 07:08:13 AM Re:Bitmap image is not valid try TBlobStream.Create(TBlobField(qry.FieldByName('Image')),bmRead); TBlobStream.position:=0; //rewind the stream Peter Below (TeamB) Delphi Developer 2005-08-24 05:39:30 PM Re:Bitmap image is not valid In article <430bab60$XXXX@XXXXX.COM>, Preston writes: Quote I have bitmap that is loading windows\soapbubbles.bmp. If I do a load from file it works fine. If I save it to a database and then do a load from stream it throws a 'Bitmap image is not valid' error. Other bitmaps seems to work ok. However from looking at their size, I suspect that soapbubbles is 24 or 32 bit,
to this Thread Search Forum Back to Thread List Replies: 2 - Last Post: Jun 1, 2015 11:42 AM Last Post By: Bennie Coetzer Bennie
Bitmap Is Not Valid Android
Coetzer Posts: 35 Registered: 12/2/03 Bitmap image not valid Reply Posted: May 30, 2015 9:44 AM I have a problem with code that worked but cannot find the error. I am using XE8, VCL I used this successfully before (TempField = TBlobField, TheBMP = TBitmap, already created) TempField := TBlobField(MyQry.FieldByName('IMAGE')); TheBMP.Assign(TempField); However, now it http://www.delphigroups.info/2/3/312518.html complains that the bitmap is not valid when I assign the field to the BMP I then tried TempField .SaveToFile('D:\Data\Data_BC\Temp\apic.bmp'); aBMP := TBitmap.create; aBMP.LoadFromFile('D:\Data\Data_BC\Temp\apic.bmp'); It still fails when I execute the aBMP.LoadFromFile instruction, even though I can read the images in the file with any image viewer. If I simply load an image created with MSPaint, https://forums.embarcadero.com/message.jspa?messageID=700976 it seems to work aBMP := TBitmap.create; aBMP.LoadFromFile('D:\Data\Data_BC\Temp\PaintImage.bmp'); It would therefore seem to me that the image retrieved in the BLOBField is not of the right format but I can read it after having been saved with Paint, but not with .loadfromfile. Is there away to check the image content and what do I look for. Incidentally, the first bit of code is used repeatedly on the same database but written in Firemonkey, not VCL (Delphi XE5) Hope someone has an idea. Edited by: Bennie Coetzer on May 30, 2015 10:40 AM Remy Lebeau (Te... Posts: 6,634 Registered: 12/23/01 Re: Bitmap image not valid [Edit] Correct Reply Posted: May 30, 2015 1:40 PM in response to: Bennie Coetzer Bennie wrote: However, now it complains that the bitmap is not valid when I assign the field to the BMP How is the blob field populated? Are you sure it is being populated with an actual bitmap and not another image format? It still fails when I execute the aBMP.LoadFromFi
links to the respective forums on SCN, or you can go to SCN and http://nntp-archive.sybase.com/nntp-archive/action/article/%253C4d120e9c$1@solutions.advantagedatabase.com%253E search for your product in the search box (upper right corner) http://www.devsuperpage.com/search/Articles.asp?ArtID=914472 to find your specific developer center. Forums Archive > Advantage DB > Delphi > "Loading JPG into Advange Blob field - Delphi Bitmap image is not valid" Loading JPG into Advange Blob field - Delphi Bitmap image is not valid 9 is not posts in Delphi . Last posting was on 2011-01-21 20:44:54.0Z Antony Posted on 2010-12-22 14:44:04.0Z Date: Wed, 22 Dec 2010 14:44:04 +0000From: Antony User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7MIME-Version: 1.0Newsgroups: Advantage.DelphiSubject: Loading JPG into Advange Blob field - Delphi Bitmap image is not validContent-Type: text/plain; charset=ISO-8859-1; format=flowedContent-Transfer-Encoding: 7bitNNTP-Posting-Host: is not valid 213.249.137.250Message-ID: <4d120e9c$1@solutions.advantagedatabase.com>X-Trace: 22 Dec 2010 06:43:40 -0800, 213.249.137.250Lines: 36Path: solutions.advantagedatabase.comXref: solutions.advantagedatabase.com Advantage.Delphi:24962 Article PK: 1119691 Hi All, Using your examples I am trying to load a jpg into a blob field but get the error Bitmap image is not valid procedure TForm1.Button1Click(Sender: TObject); var jpg:TJPEGImage; ms:TMemoryStream; begin ms:=TMemoryStream.Create; try TBlobField(table.FieldByName('item_image1')).SaveToStream(ms); ms.Position:=0; jpg:=TJPEGImage.Create; try jpg.LoadFromStream(ms); Image1.Picture.Assign(jpg); finally FreeAndNil(jpg); end; finally FreeAndNil(ms); end; end; procedure TForm1.Button2Click(Sender: TObject); begin Table.Append; TBlobField(Table.FieldByName('item_image1')).LoadFromFile('C:\IMAGE_059.jpg'); Table.Post; end; Madhumati Gopalachari Posted on 2011-01-03 19:37:52.0Z From: "Madhumati Gopalachari" Newsgroups: Advantage.DelphiReferences: <4d120e9c$1@solutions.advantagedatabase.com>Subject: Re: Loading JPG into Advange Blob field - Delphi Bitmap image is not validDate: Mon, 3 Jan 2011 14:37:52 -0500Lines: 65X-Priority: 3X-MSMail-Priority: NormalX-Newsreader: Microsoft Outlook Express 6.00.2900.5931X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994X-RFC2646: Format=Flowed; ResponseNNTP-Posting-Host: 162.39.125.18Message-ID: <4d22257f@solutions.advantagedatabase.com>X-Trace: 3 Jan 2011 11:37:35 -0800, 162.39.125.18Path: solutions.advantagedatabase.comXref: solutions.advantagedatabase.com Advantage.Delphi:24980 Article PK: 1119709 Loading a JPG into a blob field requires converting it to a bitmap image first and then loading the image into the blob field. her
file it works fine. If I save it to a database and then do a load from stream it throws a 'Bitmap image is not valid' error. Other bitmaps seems to work ok. However from looking at their size, I suspect that soapbubbles is 24 or 32 bit, where as the others are 16 (i.e. GoneFishing)? I've put the appropriate snippets of code below. Any Suggestions. with qry do begin with SQL do begin Clear; Add('INSERT INTO PrintableImages(ImageName,Image) VALUES(:ImageName,:Image)'); end; qry.ParamByName('ImageName').AsString := imageName; qry.ParamByName('Image').Loadfromfile(dlgOpenFile.Filename, ftBlob); ExecSQL; end; qry.SQL.Add('SELECT * FROM PrintableImages'); qry.Open; while not qry.EOF do begin try // Associate the field to a TStream stream := TBlobStream.Create(TBlobField(qry.FieldByName('Image')),bmRead); //Add the image as stream thumbView.AddFromStream(stream,grBMP,qry.FieldByName('ImageName').AsString); qry.Next; finally FreeAndNil(stream); end; .... Thb.Photo.LoadFromStream(AStream, Thb.StreamFileType); ..... Bmp := Graphics.TBitmap.Create; try Bmp.LoadFromStream(AStream); <<< DIES HERE Bmp.PixelFormat := pf24bit; Picture.Assign(Bmp); finally FreeAndNil(Bmp); From: Peter Below (TeamB) Subject: Re: Bitmap image is not valid NewsGroup: borland.public.delphi.graphics Date Posted: 24-Aug-2005 at 19:26:43 PST In article <430c8b43$1@newsgroups.borland.com>, Preston wrote: > It's definately 32 k. I opened an image in paint and began to scale it 1% at > a time. As soon as the image hit 33k it started failing. It's got to be the > BDE. Might be. You should ask in b.p.delphi.database.desktop or .sqlservers, depending on what kind of database you use. > -- Peter Below (TeamB) Use the newsgroup archives : http://www.mers.com/searchsite.html http://www.tamaracka.com/search.htm http://groups.google.com http://www.prolix.be From: Preston Subject: Re: Bitmap image is not valid NewsGroup: borland.public.delphi.graphics Date Posted: 24-Aug-2005 at 9:1:23 PST It's definately 32 k. I opened an image in paint and began to scale it 1% at a time. As soon as the image hit 33k it started failing. It's got to be the BDE. From: Preston Subject: Re: Bitmap image is not valid NewsGroup: borland.public.delphi.graphics Date Posted: 24-Aug-2005 at 8:54:4 PST I suspect it might be the BDE (I can't wait to migrate off it). I've adjusted the blob size to 128 from 32. That didn't help. The problem seems to be w