static void handleImage (Blip * b, long width, long height) { /* TODO: image support */ wvStream * pwv = NULL; size_t size = 0; int data = 0; int cnt = 0; int tag = time (NULL); /* short-circuit this method if we don't support the incoming format */ switch (b->type) { case msoblipPNG: /* conveniently I know how to export to PNG */ rtf_output ("{\\*\\shppict{\\pict\\pngblip\\picw%d\\pich%d\\picwgoal\\pichgoal\n", width, height); break; case msoblipDIB: case msoblipWMF: case msoblipEMF: case msoblipPICT: case msoblipJPEG: default: /* TODO: support other image types */ return; } rtf_output ("\bliptag%d{\\*\\blipuid%032x}", tag, tag); pwv = b->blip.bitmap.m_pvBits; size = wvStream_size (pwv); wvStream_rewind(pwv); while (cnt < size) { if (cnt++ % 64 == 0) rtf_output_char ('\n'); rtf_output ("%02x", read_8ubit(pwv)); } rtf_output_char ('}'); }
U32 wvGetBitmap(BitmapBlip *abm, MSOFBH *amsofbh, wvStream *fd) { U32 i, count; char extra = 0; wvStream *stm = NULL; wvTrace(("starting bitmap at %x\n", wvStream_tell(fd))); for (i = 0; i < 16; i++) abm->m_rgbUid[i] = read_8ubit(fd); count = 16; abm->m_rgbUidPrimary[0] = 0; switch (amsofbh->fbt - msofbtBlipFirst) { case msoblipPNG: wvTrace(("msoblipPNG\n")); /* sprintf(buffer,"%s-wv-%d.png",aimage,no++); */ if (amsofbh->inst ^ msobiPNG) extra = 1; break; case msoblipJPEG: wvTrace(("msoblipJPEG\n")); /* sprintf(buffer,"%s-wv-%d.jpg",aimage,no++); */ if (amsofbh->inst ^ msobiJFIF) extra = 1; break; case msoblipDIB: wvTrace(("msoblipDIB\n")); /* sprintf(buffer,"%s-wv-%d.dib",aimage,no++); */ if (amsofbh->inst ^ msobiDIB) extra = 1; break; } if (extra) { for (i = 0; i < 16; i++) abm->m_rgbUidPrimary[i] = read_8ubit(fd); count += 16; } abm->m_bTag = read_8ubit(fd); abm->m_pvBits = NULL; count++; stm = wvStream_TMP_create(amsofbh->cbLength); if (!stm) { abm->m_pvBits = NULL; return 0; } for (i = count; i < amsofbh->cbLength; i++) write_8ubit(stm, read_8ubit(fd)); wvStream_rewind(stm); abm->m_pvBits = stm; count += i; return count; }