Forums

Welcome Guest Search | Active Topics | Members

Escape the MSDN Options
Michel
Posted: Wednesday, April 27, 2005 1:11:00 AM
Rank: Member
Groups: Member

Joined: 4/25/2005
Posts: 15
Points: 0
Hello,

Is it possible to use all the functionnalities of this component without using the MSDN library ?

For example, I want to draw a text with an effect (shadow, glow, ...) and if I don't use the System.drawing namespace, it doesn't work : either the effect is applied to the bitmap (not the text) or the text is not displayed.

Thank you,

Michel
Dmitry
Posted: Wednesday, April 27, 2005 8:53:00 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 500
Points: 330
Hello, Michel,

Graphics Mill for .NET has reference to System.Drawing.dll because it imports some basic types. But you don't have to use System.Drawing.Bitmap and System.Drawing.Graphics objects to perform most of tasks. For example the following code snippet illustrates how to render text with shadow using Graphics Mill for .NET:

Code:
// Create bitmap destination bitmap.
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.White,
      300, 300, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);

// Obtain canvas from created bitmap.
Aurigma.GraphicsMill.Drawing.GdiGraphics graphics = bitmap.GetGdiGraphics();

// Draw string.
Aurigma.GraphicsMill.Drawing.Font font = new Aurigma.GraphicsMill.Drawing.Font("Arial", 30);
Aurigma.GraphicsMill.Drawing.SolidBrush brush = new Aurigma.GraphicsMill.Drawing.SolidBrush
      (Aurigma.GraphicsMill.RgbColor.Red);
graphics.DrawString("Aurigma Inc.", font, brush, 20, 20);

// Dispose unnecessary instances.
font.Dispose();
graphics.Dispose();

// Make white background transparent.
bitmap.Channels.Transparentize(Aurigma.GraphicsMill.RgbColor.White, 0.5f);

// Apply shadow effect.
bitmap.Transforms.Shadow(Aurigma.GraphicsMill.RgbColor.Black, 10, 10);

// Blend bitmap with destination background.
bitmap.Channels.DiscardAlpha(Aurigma.GraphicsMill.RgbColor.Gold);

// Save the result.
bitmap.Save(@"c:/1.png");


Sincerely yours,
Dmitry Sevostjanov.
Michel
Posted: Thursday, April 28, 2005 1:48:00 AM
Rank: Member
Groups: Member

Joined: 4/25/2005
Posts: 15
Points: 0
heu... maybe I was not explicit enough ^_^!
I don't want the effect to be applied on the image I have loaded.
I want to convert this code into 100% Aurigma code :

Code:
    Private Sub Page_Load()

        'Create bitmap object which contains image on which we want to draw text
        Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\InetPub\wwwroot\Graphics\WebMatrix\data\jack2.bmp")

        'Get width and height of the loaded image
        Dim BitmapHeight = bitmap.height
        Dim BitmapWidth = bitmap.width

        'Create bitmap with transparent background
        Dim bitmapText As New Aurigma.GraphicsMill.Bitmap(BitmapWidth, BitmapHeight, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)
        Dim graphics As System.Drawing.Graphics = bitmapText.GetGdiplusGraphics()

        'Set text output properties
        Dim font As New System.Drawing.Font("Arial", 22, FontStyle.Italic)
        Dim brush As New System.Drawing.SolidBrush(System.Drawing.Color.Blue)

        'Draw text
        graphics.DrawString("Merci jack", font, brush, 5, 5)

        'Apply shadow effect on text
        bitmapText.Transforms.Shadow(Aurigma.GraphicsMill.RgbColor.Black, 8, 8, 4, False)

        'Draw text on bitmap
        bitmapText.Draw(bitmap, 0, 0, bitmapText.Width, bitmapText.Height, _
            Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, 1, _
            Aurigma.GraphicsMill.Transforms.InterpolationMode.LowQuality)

        'Specify that we are going to save to JPEG
        Dim encoderOptions As New JpegEncoderOptions

        'Save image to response stream
        Response.Clear()

        Response.ContentType="image/jpeg"

        bitmap.Save(Response.OutputStream, encoderOptions)

        Response.End()
    End Sub


but it seems that the alpha property is not processed the same way.
Dmitry
Posted: Thursday, April 28, 2005 4:22:00 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 500
Points: 330
Hello, Michel.

Aurigma.GraphicsMill.Drawing.GdiGraphics class works through Windows GDI which unfortunately doesn't operate with alpha. The following sample is written on pure Graphics Mill for .NET and solves this problem:

Code:
'Create bitmap object which contains image on which we want to draw text
Dim bitmap As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.Yellow, 200, 200, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)

'Get width and height of the loaded image
Dim BitmapHeight = bitmap.Height
Dim BitmapWidth = bitmap.Width

'Create bitmap with transparent background
Dim bitmapText As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.White, BitmapWidth, BitmapHeight, _
      Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmapText.GetGdiGraphics()

'Set text output properties
Dim font As New Aurigma.GraphicsMill.Drawing.Font("Arial", 22, True, False)
Dim brush As New Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Blue)

'Draw text
graphics.DrawString("Merci jack", font, brush, 5, 5)

'Dispose graphics
graphics.Dispose()

'Make white background tranparent
bitmapText.Channels.Transparentize(Aurigma.GraphicsMill.RgbColor.White, 0.2)

'Apply shadow effect on text
bitmapText.Transforms.Shadow(Aurigma.GraphicsMill.RgbColor.Black, 8, 8, 4, False)

'Draw text on bitmap
bitmapText.Draw(bitmap, 0, 0, bitmapText.Width, bitmapText.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, _
      1, Aurigma.GraphicsMill.Transforms.InterpolationMode.LowQuality)

bitmap.Save("c:\1.jpg")


Sincerely yours,
Dmitry Sevostjanov.
Michel
Posted: Thursday, April 28, 2005 6:04:00 AM
Rank: Member
Groups: Member

Joined: 4/25/2005
Posts: 15
Points: 0
greeaaaaaat!! \\ ^_^ //
thank you very much!!
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.