Insert WMF in RTF

Source: Internet
Author: User
After five days, I want to summarize that I want to support BMP images in RTF. The WordPad does not support/dibitmap and/wbitmap control words, so I chose/wmetafile, Which is WMF. WMF is a vector graph, which contains windows APIs. BMP is actually used to draw BMP. There are several WMF types. I chose the old standard Metafile which consists of two structs: header and recordtypedef struct tagmetaheader {word mttype; Word mtheadersize; Word mtversion; DWORD mtsize; Word mtnoobjects; DWORD mtmaxrecord; Word mtnoparameters;} metaheader, * pmetaheader;
typedef struct tagMETARECORD {   DWORD rdSize;   WORD  rdFunction;   WORD  rdParm[1]; } METARECORD, *PMETARECORD; 
Http://wvware.sourceforge.net/caolan/ora-wmf.html on the Internet
I used word to generate an illustrated RTF document, read the code, and then complete the // Header
0100 -- type
0900 -- header size
0003 -- version
4e000000 -- size 78
0000 -- objects
2a1000000 -- maxrecord 42
0000
// Record
04000000 -- size
0301 -- setmapmode
0800 -- mm_anisotropic05000000
0b02 -- set0000worg
0000
000005000000
0c02 -- setjavaswext
0200
020005000000
0701 -- setstretchbltmode
0400
20172a000000
Effecf -- stretchdibits
2000 -- DWORD dwrop // raster operation code
Cc00 -- uint iusage, // usage options
-- Const bitmapinfo * lpbitsinfo, // bitmap data
-- Const void * lpbits, // bitmap bits
0000
0200 -- int nscheight, // height of source rectangle
0200 -- int nscwidth, // width of source rectangle
0000 -- int ysrc, // y-coord of source upper-left corner
0000 -- int xsrc, // X-coord of source upper-left corner
0200 -- int ndestheight, // height of destination rectangle
0200 -- int ndestwidth, // width of destination rectangle
0000 -- int ydest, // y-coord of destination upper-left corner
0000 -- int xdest, // X-coord of destination upper-left corner -- HDC, // handle to DC
BMP info
2800
0000
02000000
02000000
01001800000000001000
0000c40e
0000c40e
00000000
00000000
0000
Effecff0000ff4e000000ff0000ff0000 05000000
0701
0100
000003000000 -- end
0000 the parameter of the function stretchdibits in the middle is not correct. I don't know how it works, however, all the useful parameters can be seen to support BMP, but the image size is always unsatisfactory./picwn/pichn (N equals to the width or height of the image multiplied by 01MM mm per pixel, that is, hmm_per_inch, that is, n = width * 2540/DPI)/picwgoa1/ pichgoal (N equals the image width or height multiplied by twip per pixel, that is, twips_per_inch, that is, n = width/DPI * 20) /picscalex/picscaley this is the adjustment ratio (the next 20 twips are equal to one pixel, which is the unit of RTF) these control tokens related to the image size cannot be controlled. Later, it was found that word would force everything to be changed to 96 DPI and scaled half of the larger image, after all the data is complete, all data will be magnified by 4/3 times except the image. It took me a week to figure it out. If something is wrong, I hope my friend will point it out.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.