关闭

关于图片读取的问题!

255人阅读 评论(0) 收藏 举报
一段代码,读写BMP  JPEG
void myfun::Write_Picture(String &sql,String &ColName_Picture,TImage *img)
{
  //写
  // 记住一定要在post前delete   TADOBlobStream对象。
  TADOQuery *qry1 = new TADOQuery(NULL);
  qry1- >Connection = con;
  qry1- >Close() ;
  qry1- >SQL- >Clear() ;
  qry1- >SQL- >Text = sql ;
  qry1- >Open() ;
  qry1- >Close() ;
  qry1- >Open() ;
  qry1- >Edit();
  TBlobField   *   pField=(TBlobField   *)qry1- >FieldByName(ColName_Picture);
  TADOBlobStream   *   pmem=new   TADOBlobStream   (pField,bmWrite);
  pmem- >Seek(0,soFromBeginning);
  Graphics::TBitmap   *   pBitmap=new   Graphics::TBitmap();
  pBitmap- >Assign(img- >Picture- >Graphic);
  pBitmap- >SaveToStream(pmem);
  delete   pBitmap;
  delete   pmem;
  qry1- >Post();
  delete qry1;
}
void myfun::Read_Picture(String &sql,String &ColName_Picture,TImage *img)
{
  //读
  TADOQuery *qry = new TADOQuery(NULL);
  qry- >Connection = con;
  qry- >Close() ;
  qry- >SQL- >Clear() ;
  qry- >SQL- >Text = sql ;
  qry- >Open() ;
  TBlobField * pField=(TBlobField   *)qry- >FieldByName(ColName_Picture);
  TADOBlobStream* pmem=new TADOBlobStream(pField,bmRead);
  pmem- >Seek(0,soFromBeginning);
  Graphics::TBitmap * pBitmap=new Graphics::TBitmap();
  pBitmap- >LoadFromStream(pmem);   
  img- >Picture- >Bitmap- >Assign(pBitmap);
  delete   pBitmap;   
  delete   pmem;
  delete qry;
}
 
 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1104次
    • 积分:29
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:0篇
    • 译文:0篇
    • 评论:1条
    文章存档