powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Динамическое создание картинки вэб-сайта
5 сообщений из 5, страница 1 из 1
Динамическое создание картинки вэб-сайта
    #33827484
Аноним
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Помогите в таком вопросе — нужно динамически создавать картинку определённой страницы вэб-сайта по URL и сохранять результат в jpeg.
...
Рейтинг: 0 / 0
Динамическое создание картинки вэб-сайта
    #33827576
C...R...a...S...H
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
<%@ Page Language="VB" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">

Private Sub Page_Load(sender As Object, e As EventArgs)
' 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.
Dim rectangleFont As New Font( _
"Arial", 10, FontStyle.Bold)

' Create integer variables.
Dim height As Integer = 100
Dim width As Integer = 200

' Create a random number generator and create
' variable values based on it.
Dim r As New Random()
Dim x As Integer = r.Next(75)
Dim a As Integer = r.Next(155)
Dim x1 As Integer = r.Next(100)

' Create a bitmap and use it to create a
' Graphics object.
Dim bmp As New Bitmap( _
width, height, PixelFormat.Format24bppRgb)
Dim g As Graphics = 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()
End Sub 'Page_Load

</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>----------------------------------------
Knowledge is power!
My site
...
Рейтинг: 0 / 0
Динамическое создание картинки вэб-сайта
    #33827723
Аноним
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Записать не проблема — проблема получить картинку самой страницы — её скриншот.
...
Рейтинг: 0 / 0
Динамическое создание картинки вэб-сайта
    #33867221
Sobaka WWW
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А не подскажете еод такой же , тока ни си шарпе ?
Сорри за лень )))
...
Рейтинг: 0 / 0
Динамическое создание картинки вэб-сайта
    #33867296
C...R...a...S...H
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Можно и на Шарпее
<%@ Page Language="C#" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ import Namespace="System.Drawing.Drawing2D" %>

<script runat="server">

private 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();
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>

Пример то из МСДН----------------------------------------
Knowledge is P...O...w...E...R!
My site
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Динамическое создание картинки вэб-сайта
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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