Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Crimblepud  
#1 Posted : Wednesday, May 31, 2006 7:38:52 PM(UTC)
Crimblepud

Rank: Member

Groups: Member
Joined: 5/23/2006(UTC)
Posts: 11

Can anyone help me with this?
I am trying to create some buttons by using DrawText and applying a glow to the text using ArtisticEffects.Glow.
I can get this to work fine when using JPEG as image format, but as soon as I try to convert it to a gif, it all goes wrong.
The following code gives the result I want to achieve using a JPEG:

Code:
<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Option Explicit
Response.Buffer = true
Dim strString
strString = "Text Is Text"
' Create the Bitmap object...
Dim objBitmap
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
' Create bitmap with transparent background...
objBitmap.CreateNew 300, 150, Format32bppArgb, &h00000000
' Now draw the text...
With objBitmap.Graphics 
	.Engine = DrawingEngineGdiplus
	.Antialiasing = true
	' Set text output properties...
	.Unit = UnitPoint
	.TextFormat.FontName = "Impress BT"
	.TextFormat.FontColor = .Color.CreateRGB(73, 1, 73)
	.TextFormat.FontSize = 48
	.TextFormat.HorizontalAlignment = HorizontalAlignmentCenter
	.TextFormat.VerticalAlignment = VerticalAlignmentBottom
	' Text to be drawn with X/Y co-ordinates...
	.Unit = UnitPixel
	.DrawText strString, 150, 140
End With
' Apply glow effect on text...
objBitmap.ArtisticEffects.Glow objBitmap.Graphics.Color.CreateRGB(64, 57, 161), 10, false
' Set image format...
objBitmap.Formats.SelectCurrent "JPEG"
objBitmap.Formats.JpegIsProgressive = True
objBitmap.Formats.JpegQuality = 100
' Save image to response stream (e.g. draw to page)...
objBitmap.SaveToStream Response
Set objBitmap = Nothing
%>


I change the following code:

Code:
	' Set image format...
	objBitmap.Formats.SelectCurrent "JPEG"
	objBitmap.Formats.JpegIsProgressive = True
	objBitmap.Formats.JpegQuality = 100


To:

Code:
	' Set image format...
	objBitmap.Formats.SelectCurrent "GIF"
	objBitmap.Data.ConvertTo8bppIndexed
	objBitmap.Data.Palette.SetTransparentColor objBitmap.Graphics.Color.CreateRGB(63, 56, 160)
	objBitmap.Formats.GifIsTransparent = true
	objBitmap.IsLzwEnabled = true


And despite playing with different values for ConvertTo8bppIndexed & SetTransparentColor, and the dithering, I cannot get a gif anywhere near that created when I set the format to JPEG.
Does anyone have any idea as to where I am going wrong, or any example code to create text with a glow saving it to a (transparent) GIF?
Reagrds, Crimblepud

Edited by user Wednesday, December 19, 2007 4:33:50 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Wednesday, May 31, 2006 11:32:31 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
After you apply glow effect, you should discard alpha channel of the image. To do it, convert the image to 24-bit RGB and specify to flatten alpha with a white color (or whatever else color which you will use as a transparent):

Code:
'...
objBitmap.ArtisticEffects.Glow objBitmap.Graphics.Color.CreateRGB(64, 57, 161), 10, false
[b]objBitmap.Data.ConvertTo24bppRgb True, ColorWhite[/b]
'...


After that you can convert it to 8-bit indexed bitmap and set transparent palette entry:

Code:
'...
objBitmap.Formats.SelectCurrent "GIF"
objBitmap.Data.ConvertTo8bppIndexed 
objBitmap.Data.Palette.SetTransparentColor ColorWhite
objBitmap.Formats.GifIsTransparent = true
objBitmap.IsLzwEnabled = true
'...


Result is attached.

Edited by user Wednesday, December 19, 2007 4:34:18 PM(UTC)  | Reason: Not specified

Andrew attached the following image(s):
artistic2.asp.gif
Crimblepud  
#3 Posted : Thursday, June 1, 2006 4:31:05 PM(UTC)
Crimblepud

Rank: Member

Groups: Member
Joined: 5/23/2006(UTC)
Posts: 11

Great.
Many Thanks.
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.