将图片文件以二进制文件读入,存入image数据类型的项中.

解决方案 »

  1.   

    可以用ado的stream对象可以轻松读进去
      

  2.   

    TStream * bs = ptQuery->CreateBlobStream( ptQuery->FieldByName( "picture_content" ), bmRead);
        if( ptQuery->FieldByName( "picture_type_id" )->AsInteger == 0 )
        {
            TJPEGImage *j=new TJPEGImage;
            bs->Position=0;
            j->LoadFromStream(bs);
            Image2->Picture->Assign( j ) ;
            delete j;
        }
        else if ( ptQuery->FieldByName( "picture_type_id" )->AsInteger == 1 )
        {
            Graphics::TBitmap * Bit=new Graphics::TBitmap();
            Bit->LoadFromStream( bs );
            Image2->Picture->Bitmap = Bit ;
            delete Bit ;
        }
        else
        {
            TIcon * ic = new TIcon ;
            ic->LoadFromStream( bs );
            Image2->Picture->Icon = ic ;
            delete ic ;
        }