문제

내 자신의 GIF 이미지를 프로그래밍 방식으로 생성하는 데 사용할 수있는 .NET 라이브러리가 있습니까?

최소한 Pixel-by-Pixel을 만들고 싶습니다. 텍스트와 모양을 지원하는 것이 좋습니다.

다음은 내가하려는 일의 예입니다. 나는 이것을 Photoshop에서 조롱했다…

번호 라인 그래픽 http://img143.imageshack.us/img143/5458/dollarlineot9.gif

추천 메뉴가 무엇인가요?

도움이 되었습니까?

해결책

Bitmap bmp = new Bitmap(xSize, ySize, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(bmp)) {
  // Use g and/or bmp to set pixels, draw lines, show text, etc...
}
bmp.Save(filename, ImageFormat.Gif);

작업이 완료되었습니다

다른 팁

이 외에도 bmp.Save(filename, ImageFormat.Gif); 방법, a bmp.Save(stream, ImageFormat.Gif); 이를 통해 서버에 하드 디스크에 저장되지 않고 이미지를 웹 페이지에 생성 및 출력 할 수 있습니다.

다음은 System.Drawing 네임 스페이스. 단순히 픽셀을 설정하는 것보다 더 높은 레벨에서 모양을지지하는 두 개의 상자가있는 선을 그립니다.

// add a reference to System.Drawing.dll
using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Bitmap bmp = new Bitmap(400, 100);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.FillRectangle(Brushes.White, 0.0f, 0.0f, 400f, 100f);

                // draw line
                using (Pen p = new Pen(Color.Black, 1.0f))
                {
                    g.DrawLine(p, 0, 49, 399, 49);
                }

                // Draw boxes at start and end
                g.FillRectangle(Brushes.Blue, 0, 47, 5, 5);
                g.FillRectangle(Brushes.Blue, 394, 47, 5, 5);
            }


            bmp.Save("test.gif", ImageFormat.Gif);
            bmp.Dispose();
        }
    }
}

httphandler를 사용하여 이미지를 만들고 스트림으로 전송하는 방법의 예입니다 (이미 이미지 코드를 사용하여 이미 이미지 코드를 사용).

사용:

<img src="createChart.ashx?data=1"/>

암호:

public class CreateChart : IHttpHandler
{
     public void ProcessRequest(HttpContext context)
     {
        string data = context.QueryString["data"]; // Or get it from a POST etc

        Bitmap image = new Bitmap(xSize, ySize, PixelFormat.Format32bppArgb);
        using (Graphics g = Graphics.FromImage(Image)) 
        {
           // Use g to set pixels, draw lines, show text, etc...
        }
        BinaryStream s = new BinaryStream();

        image.Save(s, ImageFormat.Gif);

        context.Response.Clear();
        context.Response.ContentType = "image/gif";
        context.Response.BinaryWrite(s);
        context.Response.End();
     }

     public bool IsReusable { get { return false; } }
}

왜 시스템을 사용하지 않습니까? 필요한 모든 것이 있어야합니다.

GIF를 생성하는 대신 차트 컨트롤을 사용하지 않는 이유는 무엇입니까? 이 특정 GIF를 생성하기위한 요구 사항이 엄격하지 않으면 차트 컨트롤을 사용하면 더 많은 유연성을 제공한다고 생각합니다.

좋아요 우리 회사의 제품. 당신은 GIF를 읽고 쓰고 전체 천으로 만들 수 있습니다. 서버 용 라이센스가 부여 된 데스크탑 앱 용 런타임 로열티 무료입니다.

ASP.Net과 함께 즉시 이미지 생성 (2002 년 2 월 22 일) Stephen Walther의

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top