Aspimage components implementation process
Before reading this article, it is best to have access to the following GDI Use the ATL to generate the component STLASP Using Component Aspimage is a very good component on the ServerObjects site, which allows us to use ASP to implement a lot of processing features for graphics, his Powerful, if you need to know more detailed information you can access its official website, you don't talk about how to use this component here, what we have to do this, of course, the following example uses GDI Not the only way to implement component graphics processing, you can try other methods yourself. The following is the implementation process 1. First use the Visual C wizard to establish an ATL project 2, next to add an ATL Active Server Page component interface class three, Generate classes named asppiccom, and select ASP internal object Response 4, add attributes and methods on the IASPCM interface, as follows
Name Category Meaning Call Method FontName Attribute Font Name String Type Usage How to Use. FontName = "Song" FontSize Attribute Font Size Integer How to Use Property Font Type Shaped Regular = 0, Bold = 1, Italic = 2, BoldiC = 3, underline = 4, strikeout = 8 Usage. FontStyle = 8imgFormat Property Graphics Format String Type Image / Gif Image / JPEG Image / BMP ... Usage. IMGFORMAT = "Image / GIF" setFontColor method settings Font Color How to use. The numbers ofsetfontcolor 255, 3,242,4 represents Alpha, Red, Green, BlueSetBackColor Method, set font background color usage .SetBackColor 255, 3,242,4 The numbers on the above representations Alpha, Red, Green, BlueshowPIC Method Send pictures to the client usage. SHOWPIC 5. To use GDI in the ASP component, you need to add some code 1, you need to add the following two lines in the stdafx.h file: #include
Bitmap bitmap (1,1, PixelFormat48bppRGB); Graphics graphics (& bitmap); USES_CONVERSION; Font font (OLE2CW (m_bstrFontName), (float) m_fFontSize, m_nFontStyle, UnitPoint, NULL); PointF origin (0, 0); StringFormat format; format .SetAlignment (StringAlignmentCenter); RectF boundRect; graphics.MeasureString (OLE2CW (m_bstrText), m_bstrText.Length (), & font, origin, & format, & boundRect); int nWidth = (int) boundRect.Width; int nHeight = (int) boundRect .Height; Bitmap bm (nWidth, nHeight, PixelFormat48bppRGB); boundRect.Width = boundRect.Width * 2;; Graphics * g = Graphics :: (& bm) FromImage SolidBrush solidbrush (m_cBackground); g-> FillRectangle (& solidbrush, boundRect) ; SolidBrush SolidFont (m_cFontColor); PointF fPoint (0,0); g-> DrawString (OLE2CW (m_bstrText), m_bstrText.Length (), & font, fPoint, & SolidFont); int result; CLSID pngClsid; result = GetCodecClsid (OLE2W ( m_btrimgformat); HRESULT HR; HGLOBAL HGLOBAL = GLOBALLOC (GMEM_MOVEABLE, 0); ccomptr
7. Now the implementation of the component is highly gotten. We write a paragraph ASP to test the following components <% @ language = "vbscript" codepage = "936"%>
<% set picture = server.createObject "Asppic.asppiccom") Picture.Text = "Can you see me? I am from www.goodassister.com!" Picture.FontName = "black body" Picture.FontSize = 40 Picture.Imgformat = "image / jpeg" Picture.FontStyle = 1 Picture.SetFontColor 255, 3, 242, 4 'represents Alpha, Red, Green, Blue Picture.SetBackColor 10,243,42,54' represents Alpha, Red, Green, Blue Picture.ShowPic Set Picture = Nothing%> body> < / html> Note: In the User Registration Components Regsvr32 asppic.dll Open this ASP page, you will see the following picture Now achieve the specific ideas of Aspimage, now you need more effects, you can enrich your own This component looks out: This type of component is very wide, such as Yahoo.com registered a graphic word to prevent computer from automatically register, because the computer should identify the text on the picture is inefficient and it is very difficult, this class Components are more use to build to the chart, such as histogram, pie chart, waveform, etc. This article is written here. If you think there is any opinion or I am wrong place, please tell me email: sillyboy@china.com THX