This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.
Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Michel  
#1 Posted : Tuesday, April 26, 2005 5:11:00 PM(UTC)
Michel

Rank: Member

Groups: Member
Joined: 4/24/2005(UTC)
Posts: 15

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  
#2 Posted : Wednesday, April 27, 2005 12:53:00 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
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");

Edited by user Monday, December 24, 2007 3:37:11 PM(UTC)  | Reason: Not specified

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

Michel  
#3 Posted : Wednesday, April 27, 2005 5:48:00 PM(UTC)
Michel

Rank: Member

Groups: Member
Joined: 4/24/2005(UTC)
Posts: 15

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.

Edited by user Monday, December 24, 2007 3:37:34 PM(UTC)  | Reason: Not specified

Dmitry  
#4 Posted : Wednesday, April 27, 2005 8:22:00 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
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")

Edited by user Monday, December 24, 2007 3:37:48 PM(UTC)  | Reason: Not specified

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

Michel  
#5 Posted : Wednesday, April 27, 2005 10:04:00 PM(UTC)
Michel

Rank: Member

Groups: Member
Joined: 4/24/2005(UTC)
Posts: 15

greeaaaaaat!! \\ ^_^ //

thank you very much!!

Users browsing this topic
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.