Interface design of COM components
Before we enter the text, in the program to create a device context, the input text to calculate and output the specified file name of the bitmap file, in this design, we use the JPEG compressed format to store files in order to reduce network transmission time, because the JPEG compression method of the discussion is beyond the scope of this article, so no longer Repeating.
In order for other languages to call this interface, we publish this program as a COM component, which can be called by vb,delphi,pb,asp and other programs, the following gives the design method of COM components, the General COM component is created and compiled beyond the scope of this article, so no longer explain.
To clear the method in the assembly:
STDMETHOD(OutTextImg) (/*[out, retval]*/ long *pVal);ltvalue(500)] long lWeight,
[in,optional,defaultvalue(0)] long l3D);
And
STDMETHOD(OutImg) (BSTR bstrFileName, long lDelFile);
The processing file is saved as an image and the image is exported to the user's browser respectively. The implementation code is as follows:
STDMETHODIMP CAspImage::OutImgFromText(BSTR bstrFilePath,
BSTR bstrText,
BSTR bstrBgImg,
long lCSet,
BSTR bstrFont,
long lWidth,
long lHeight,
long lLeft,
long lTop,
long llfHeight,
long lWeight,
long l3D)
{
CImg img;
try{
if(0 == img.OutImgFromText(
bstrFilePath,
bstrText,
bstrBgImg,
lCSet,
bstrFont,
lWidth,
lHeight,
lLeft,
lTop,
llfHeight,
lWeight,
l3D))
{
return S_OK;
}
else
{
return S_FALSE;
}
}
catch(...)
{
return S_FALSE;
}
return S_OK;
/**/
}