Y ymf Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #1 我 的Access数据库“OLE 对象”字段中存放着一个位图数据(没有文件头信息, 一个象素=8 bit,图象高度和宽度信息在其它字段中), 请问如何将此图象在Image中显示出来?
A Another_eYes Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #3 没有头信息你怎么知道位图多宽多高,多少bit表示一个像素呀?
Y ymf Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #5 to Another_eYes 一个象素=8 bit,图象高度和宽度在其它字段中
A Another_eYes Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #6 那就很简单了。 (从数据库读出部分略, 假设读出后保存在buffer变量里) type TColorEntry = packed record b, g, r, a: Byte; end; TBitmapInfo256 = record bmiHeader: TBitmapInfoHeader; ColorEntry: array [0..255] of TColorEntry; end; var buffer: pointer; hbmp: HBITMAP; bmInfo: TBitmapInfo256; begin bmInfo.bmiHeader.biSize:=SizeOf(TBitmapInfoHeader); bmInfo.bmiHeader.biPlanes:=1; bmInfo.bmiHeader.biBitCount:=8; bmInfo.bmiHeader.biCompression:=BI_RGB; bmInfo.bmiHeader.biWidth:=adodataset1.fieldbyname('bmpwidth').asinteger; bmInfo.bmiHeader.biHeight:=adodataset1.fieldbyname('bmpheight').asinteger; hbmp := createDIBSection(0, bminfo, DIB_RGB_COLORS, buffer, 0, 0); Image1.picture.bitmap.handle := hbmp; end;
那就很简单了。 (从数据库读出部分略, 假设读出后保存在buffer变量里) type TColorEntry = packed record b, g, r, a: Byte; end; TBitmapInfo256 = record bmiHeader: TBitmapInfoHeader; ColorEntry: array [0..255] of TColorEntry; end; var buffer: pointer; hbmp: HBITMAP; bmInfo: TBitmapInfo256; begin bmInfo.bmiHeader.biSize:=SizeOf(TBitmapInfoHeader); bmInfo.bmiHeader.biPlanes:=1; bmInfo.bmiHeader.biBitCount:=8; bmInfo.bmiHeader.biCompression:=BI_RGB; bmInfo.bmiHeader.biWidth:=adodataset1.fieldbyname('bmpwidth').asinteger; bmInfo.bmiHeader.biHeight:=adodataset1.fieldbyname('bmpheight').asinteger; hbmp := createDIBSection(0, bminfo, DIB_RGB_COLORS, buffer, 0, 0); Image1.picture.bitmap.handle := hbmp; end;
Y ymf Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #7 to Another_eYes 请问你如何把图象数据读到buffer中(不要笑我,我很菜的 ^-^),还有下面有的地方不懂请你解释一下 var buffer: pointer; hbmp: HBITMAP;//这是一个什么类型 bmInfo: TBitmapInfo256; begin bmInfo.bmiHeader.biSize:=SizeOf(TBitmapInfoHeader); bmInfo.bmiHeader.biPlanes:=1; bmInfo.bmiHeader.biBitCount:=8; bmInfo.bmiHeader.biCompression:=BI_RGB; bmInfo.bmiHeader.biWidth:=adodataset1.fieldbyname('bmpwidth').asinteger; bmInfo.bmiHeader.biHeight:=adodataset1.fieldbyname('bmpheight').asinteger; hbmp := createDIBSection(0, bminfo, DIB_RGB_COLORS, buffer, 0, 0);// 这里编译出错:Incompatible types: 'tagBITMAPINFO' and 'TBitmapInfo256' Image1.picture.bitmap.handle := hbmp; end;
to Another_eYes 请问你如何把图象数据读到buffer中(不要笑我,我很菜的 ^-^),还有下面有的地方不懂请你解释一下 var buffer: pointer; hbmp: HBITMAP;//这是一个什么类型 bmInfo: TBitmapInfo256; begin bmInfo.bmiHeader.biSize:=SizeOf(TBitmapInfoHeader); bmInfo.bmiHeader.biPlanes:=1; bmInfo.bmiHeader.biBitCount:=8; bmInfo.bmiHeader.biCompression:=BI_RGB; bmInfo.bmiHeader.biWidth:=adodataset1.fieldbyname('bmpwidth').asinteger; bmInfo.bmiHeader.biHeight:=adodataset1.fieldbyname('bmpheight').asinteger; hbmp := createDIBSection(0, bminfo, DIB_RGB_COLORS, buffer, 0, 0);// 这里编译出错:Incompatible types: 'tagBITMAPINFO' and 'TBitmapInfo256' Image1.picture.bitmap.handle := hbmp; end;
A Another_eYes Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #10 不好意思, 代码里忘了, 你强制类型转换一下就可以了。 hbmp := CreateDIBSection(0, PBitmapInfo(@bmInfo)^, DIB_RGB_COLORS, buffer, 0, 0); 从数据库读出(假设你用ado控件): 代码: var stream: TADOBlobStream; buffer: Pointer; begin stream := TADOBlobStream.Create(TBlobField(ADODataSet1.Fieldbyname('图像字段')), bmRead); getmem(buffer, stream.size); stream.Read(PChar(buffer)^, stream.size); stream.free; end;
不好意思, 代码里忘了, 你强制类型转换一下就可以了。 hbmp := CreateDIBSection(0, PBitmapInfo(@bmInfo)^, DIB_RGB_COLORS, buffer, 0, 0); 从数据库读出(假设你用ado控件): 代码: var stream: TADOBlobStream; buffer: Pointer; begin stream := TADOBlobStream.Create(TBlobField(ADODataSet1.Fieldbyname('图像字段')), bmRead); getmem(buffer, stream.size); stream.Read(PChar(buffer)^, stream.size); stream.free; end;
Y ymf Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-15 #11 Another_eYes大虾,接受答案了,不过还要麻烦你一下,请看: http://expert.csdn.net/Expert/topic/1176/1176496.xml?temp=.8184015
Another_eYes大虾,接受答案了,不过还要麻烦你一下,请看: http://expert.csdn.net/Expert/topic/1176/1176496.xml?temp=.8184015