高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】how to save preview in new file
how to save preview in new file?
how to save preview in new file?
hi everyone,
i want to save preview in new file and i already have it in my application. in the "old days" we used to call adaddbmpfrombuffer(ad_db_handle handle,void *buffer,unsigned short size) to do that.
should i call oddbdatabase::setthumbnailbitmap(const void* pbmpdata, oduint32 ndatalength) to do the same thing? i tried it but the program crashes.
should pbmpdata be in the same format as it is in odt? what is the meaning of ndatalength?
thanks.
crash is caused by dd bug. fix will be available in next release. i can e-mail the fix to clients having source code.
pbmpdata should point to bitmapinfoheader structure followed by other dib stuff. unlike odt there parameter points to bitmapfileheader.
nlength is the length of data.
sample code:
// if preview bitmap is already available it can be specified to avoid wasting
// time on generating it by dd
const odchar* pbmpfilename = "preview.bmp";
if(: dsystemservices()->accessfile(pbmpfilename, oda::kfileread))
{
odrdfilebuf bmpfile(pbmpfilename);
odarray<oduint8> buf;
buf.resize(bmpfile.length());
oduint8 * pdata = buf.asarrayptr();
bmpfile.getbytes(pdata, buf.length());
// get length taking care about big-endian
oduint32 length = pdata[2] + (pdata[3] << 8);
pdata += 14; // skip bitmapfileheader
pdb->setthumbnailbitmap(pdata, length);
}
sergey slezkin
is this bug fixed in 1.07 beta? my program crash on this operation too.
best regards,
ivan obraztsov
dd 1.07 does not contain the fix.
sergey slezkin
|