다음은 두개의 이미지를 투명 합성해서 카운터를 그리는 예제입니다.
의도와 비슷한지는 모르겠지만.. ColorMatrix로 투명처리를 하면 될듯 싶기도
한데.. GIF로 저장되구요. asp.net 코드 입니다.
참고한 사이트는 http://www.codeproject.com/vcpp/gdiplus/AlphaBlending.asp
여깁니다. 그럼 :)
<%@ Page Language="C#" runat=server %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script language="C#" runat=server>
long number = 30102;
Bitmap b;
Graphics g;
const int width = 800;
const int height = 600;
void Page_Init()
{
b = new Bitmap(width, height);
Bitmap bImg1 = new Bitmap(Server.MapPath("img1.jpg"));
Bitmap bImg2 = new Bitmap(Server.MapPath("img2.jpg"));
float[][] colorItem = {
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 0.3f, 0},
new float[] {0, 0, 0, 0, 1}
};
ColorMatrix colorMatrix = new ColorMatrix(colorItem);
ImageAttributes imageatt = new ImageAttributes();
imageatt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
g = Graphics.FromImage(b);
g.FillRectangle (new SolidBrush(Color.DarkBlue), 0, 0, width-1, height-1);
g.FillRectangle (new SolidBrush(Color.Yellow), 0, 0, 10-1, height-1);
Font countFont = new Font("Tahoma", 7, FontStyle.Bold);
SolidBrush fontColor = new SolidBrush(Color.White);
SizeF counterText = g.MeasureString(number.ToString(), countFont);
g.DrawString(number.ToString(), countFont, fontColor,
(b.Width)-((counterText.Width)+5), 3);
g.DrawImage(bImg1, new PointF(0.0F, 0.0F));
g.DrawImage(bImg2, new Rectangle(100, 0, bImg2.Width, bImg2.Height), 0.0f,
100.0f, bImg2.Width, bImg2.Height, GraphicsUnit.Pixel, imageatt);
b.Save(Response.OutputStream, ImageFormat.Gif);
}
</script>
'ASP.NET' 카테고리의 다른 글
ASP.NET 마스터하기: 사용자 지정 엔터티 클래스 소개 (0) | 2005.05.21 |
---|---|
asx 리스트 만들기 | (0) | 2005.05.21 |
자바스크립트 asp.net 에서 좋은것.. (0) | 2005.05.02 |
오옷 한글 입력만 대게 하거나. 거시기 하게 하는 스타일 쉬트 (0) | 2005.05.01 |
Visual Studio 실습 예제 (0) | 2005.04.29 |