Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Вопрос по генерации картинок , хэлп )) / 2 сообщений из 2, страница 1 из 1
20.07.2006, 16:54
    #33867799
SobakaWWW
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по генерации картинок , хэлп ))
Пользуюсь кодом
 protected void Page_Load(object sender, EventArgs e)
    {
        // Set the page's content type to JPEG files
        // and clear all response headers.
        Response.ContentType = "image/jpeg";
        Response.Clear();
   
        // Buffer response so that page is sent
        // after processing is complete.
        Response.BufferOutput = true;
   
        // Create a font style.
        Font rectangleFont = new Font(
            "Arial", 10, FontStyle.Bold);
   
        // Create integer variables.
        int height = 100;
        int width = 200;
   
        // Create a random number generator and create
        // variable values based on it.
        Random r = new Random();
        int x = r.Next(75);
        int a = r.Next(155);
        int x1 = r.Next(100);
   
        // Create a bitmap and use it to create a
        // Graphics object.
        Bitmap bmp = new Bitmap(
            width, height, PixelFormat.Format24bppRgb);
        Graphics g = Graphics.FromImage(bmp);
   
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.Clear(Color.LightGray);
   
        // Use the Graphics object to draw three rectangles.
        g.DrawRectangle(Pens.White, 1, 1, width-3, height-3);
        g.DrawRectangle(Pens.Aquamarine, 2, 2, width-3, height-3);
        g.DrawRectangle(Pens.Black, 0, 0, width, height);
   
        // Use the Graphics object to write a string
        // on the rectangles.
        g.DrawString(
            "ASP.NET Samples", rectangleFont,
            SystemBrushes.WindowText, new PointF(10, 40));
   
        // Apply color to two of the rectangles.
        g.FillRectangle(
            new SolidBrush(
                Color.FromArgb(a, 255, 128, 255)),
            x, 20, 100, 50);
   
        g.FillRectangle(
            new LinearGradientBrush(
                new Point(x, 10),
                new Point(x1 + 75, 50 + 30),
                Color.FromArgb(128, 0, 0, 128),
                Color.FromArgb(255, 255, 255, 240)),
            x1, 50, 75, 30);
        // Save the bitmap to the response stream and
        // convert it to JPEG format.
        bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
   
        // Release memory used by the Graphics object
        // and the bitmap.
        g.Dispose();
        bmp.Dispose();
   
        // Send the output to the client.
        Response.Flush();
   
    },
однако картинку получаю плохого качества, не можете подсказать, что нужно сделать для хорошего качества?
...
Рейтинг: 0 / 0
21.07.2006, 11:32
    #33869325
Nisus
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Вопрос по генерации картинок , хэлп ))
После Response.Flush(); надо обязательно делать Response.End(); иначе велика верятность того что в поток будут выведены дополнительные мусорные байты, которые, возможно, и портят вам картину(ку).
...
Рейтинг: 0 / 0
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Вопрос по генерации картинок , хэлп )) / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]