Article View: borland.public.cppbuilder.database.ado
Article #1210Using TStreamAdapter with IStream, TStream and GDI+ Images
From: Brad Arant
Date: Mon, 20 Sep 2004 20:20
Date: Mon, 20 Sep 2004 20:20
46 lines
2730 bytes
2730 bytes
Need help resolving this please if anyone can lead me in the right
direction. I am trying to resolve this with BCB6 objects as much as possible
but I have not found any examples on the net.
I am trying to load a blob image from a MSSQL database using a TADOQuery
object. The DoQuery is an object I created that encapsulates this TADOQuery
object and gives me access through the DBField method. This is all
functioning and has been tested many times without blobs and is not the
concern here.
The issue is the very last line. I am getting the old Access Violation and
appears the istream object is not working appropriately.
Any words of wisdom would be greatly appreciated.
----------------------------------------------------------------------------
-----
AnsiString SQL;
AnsiString MimeType;
CLSID ClassID;
// Create the new object entry in the objects table and get
the ID.
SQL.sprintf("select * from thumbnails where id='%i'",
ObjectID);
DoQuery(SQL);
TStream *MemStream =
DBQuery->CreateBlobStream(DBQuery->FieldByName("image_data"), bmRead);
MemStream->Seek(0, 0);
TStreamAdapter *TheStream = new
TStreamAdapter(MemStream,soReference);
IStream *istream = TheStream->operator IStream *();
DBField("image_data_mimetype", MimeType);
// Create the class ID object for the stream save.
GetEncoderCLSID(L"image/png", &ClassID);
// Load the stream buffer into the image object.
Image = new Gdiplus::Image(istream, false);
----------------------------------------------------------------------------
-----
Technical Details
Message-ID:
<414f3b5f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10698b,9a224018fd8eeca,start X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Brad Arant" <barant@barant.com> From: "Brad Arant" <barant@barant.com> Newsgroups: borland.public.cppbuilder.database.ado Subject: Using TStreamAdapter with IStream, TStream and GDI+ Images Date: Mon, 20 Sep 2004 13:20:50 -0700 Lines: 48 Organization: BARANT Technologies X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 66.12.94.132 Message-ID: <414f3b5f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095711583 66.12.94.132 (20 Sep 2004 13:19:43 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail