Rank: Member
Groups: Member
Joined: 12/29/2005(UTC) Posts: 3
|
I've been using GraphicsMill 2.0 for ActiveX happily for quite a while now. I've run into a problem lately that I cannot seem to fix. My desire is to output a PNG with a transparent background. The image is composed of multiple images and text overlays. Some of the text has a shadow added to it. When I output the graphic with a transparent background, the area that contains the shadow text seems to retain the background color. I first tried using Transparentize(), which gives the result described above: Code:<%@ LANGUAGE="VBScript" %>
<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Response.Expires = 0
Response.Buffer = true
Response.Clear
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
objBitmap.Graphics.Engine = DrawingEngineGdiPlus
objBitmap.Graphics.Antialiasing = True
objBitmap.CreateNew 600, 300, Format32bppRgb, "&hFFFFFF00"
Set objBitmapText = Server.CreateObject("GraphicsMill.Bitmap")
objBitmapText.Engine = DrawingEngineGdiplus
objBitmapText.TextFormat.FontName = "Arial"
objBitmapText.TextFormat.FontColor = "&hFFFF0000"
objBitmapText.TextFormat.FontSize = 40
objBitmapText.TextFormat.IsBold = True
TextWidth = objBitmapText.TextFormat.MeasureTextWidth("sample text")
TextHeight = objBitmapText.TextFormat.MeasureTextHeight("sample text")
objBitmapText.CreateNew TextWidth, TextHeight, Format32bppArgb, &h00FFFFFF&
objBitmapText.DrawText "sample text", 0, 0
objBitmapText.ArtisticEffects.Shadow ColorBlack, 2, 2, 4
objBitmapText.Formats.SelectCurrent "PNG"
objBitmapText.DrawOnBitmap objBitmap, 0, 0, , , , , , , CombineModeAlpha
Set objBitmapText = nothing
objBitmap.FormatAutoSelect = False
objBitmap.Channels.Transparentize "&hFFFFFF00"
objBitmap.Formats.SelectCurrent ("PNG")
objBitmap.SaveToStream Response
Set objBitmap = nothing
Response.Flush
Response.End
%>
I then tried SetTransparentColor, but this gives an error "Property Palette cannot be retrieved. Operation requires a palette, but no palette presented." This is with this code: Code:<%@ LANGUAGE="VBScript" %>
<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Response.Expires = 0
Response.Buffer = true
Response.Clear
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
objBitmap.Graphics.Engine = DrawingEngineGdiPlus
objBitmap.Graphics.Antialiasing = True
objBitmap.CreateNew 600, 300, Format32bppRgb, "&hFFFFFF00"
Set objBitmapText = Server.CreateObject("GraphicsMill.Bitmap")
objBitmapText.Engine = DrawingEngineGdiplus
objBitmapText.TextFormat.FontName = "Arial"
objBitmapText.TextFormat.FontColor = "&hFFFF0000"
objBitmapText.TextFormat.FontSize = 40
objBitmapText.TextFormat.IsBold = True
TextWidth = objBitmapText.TextFormat.MeasureTextWidth("sample text")
TextHeight = objBitmapText.TextFormat.MeasureTextHeight("sample text")
objBitmapText.CreateNew TextWidth, TextHeight, Format32bppArgb, &h00FFFFFF&
objBitmapText.DrawText "sample text", 0, 0
objBitmapText.ArtisticEffects.Shadow ColorBlack, 2, 2, 4
objBitmapText.Formats.SelectCurrent "PNG"
objBitmapText.DrawOnBitmap objBitmap, 0, 0, , , , , , , CombineModeAlpha
Set objBitmapText = nothing
objBitmap.FormatAutoSelect = False
objBitmap.Data.Palette.SetTransparentColor "&hFFFFFF00"
objBitmap.Formats.SelectCurrent ("PNG")
objBitmap.SaveToStream Response
Set objBitmap = nothing
Response.Flush
Response.End
%>
Finally, I tried a different pallette mode (ARgb versus Rgb) and setting the transparency when I created the underlying bitmap, but that had the effect of not drawing my text at all. Using this code: Code:<%@ LANGUAGE="VBScript" %>
<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Response.Expires = 0
Response.Buffer = true
Response.Clear
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
objBitmap.Graphics.Engine = DrawingEngineGdiPlus
objBitmap.Graphics.Antialiasing = True
objBitmap.CreateNew 600, 300, Format32bppARgb, "&h00FFFF00"
Set objBitmapText = Server.CreateObject("GraphicsMill.Bitmap")
objBitmapText.Engine = DrawingEngineGdiplus
objBitmapText.TextFormat.FontName = "Arial"
objBitmapText.TextFormat.FontColor = "&hFFFF0000"
objBitmapText.TextFormat.FontSize = 40
objBitmapText.TextFormat.IsBold = True
TextWidth = objBitmapText.TextFormat.MeasureTextWidth("sample text")
TextHeight = objBitmapText.TextFormat.MeasureTextHeight("sample text")
objBitmapText.CreateNew TextWidth, TextHeight, Format32bppArgb, &h00FFFFFF&
objBitmapText.DrawText "sample text", 0, 0
objBitmapText.ArtisticEffects.Shadow ColorBlack, 2, 2, 4
objBitmapText.Formats.SelectCurrent "PNG"
objBitmapText.DrawOnBitmap objBitmap, 0, 0, , , , , , , CombineModeAlpha
Set objBitmapText = nothing
objBitmap.FormatAutoSelect = False
objBitmap.Formats.SelectCurrent ("PNG")
objBitmap.SaveToStream Response
Set objBitmap = nothing
Response.Flush
Response.End
%>
What am I doing wrong, and what is the correct, recommended method of creating a composite image with a final transparent background, with all overlaying transparencies and opacities intact? My thanks. Edited by user Tuesday, December 18, 2007 3:53:51 AM(UTC)
| Reason: Not specified
|