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

Notification

Icon
Error

Options
Go to last post Go to first unread
valefar  
#1 Posted : Monday, April 30, 2007 4:22:31 AM(UTC)
valefar

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

Dmitry  
#2 Posted : Friday, May 4, 2007 5:06:26 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,

So, you need to get result image as fully transparent. How do you want to draw shadow in that case? Fade effect of shadow is implemented by cutting it through alpha channel.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
valefar  
#3 Posted : Monday, May 14, 2007 1:03:40 AM(UTC)
valefar

Rank: Member

Groups: Member
Joined: 12/29/2005(UTC)
Posts: 3

Hello.

I got around this issue by using a black background on the dropshadowed text then using CombineModeAlphaOverlapped rather than CombineModeAlpha to drop it onto the bottom (transparent) image - causing the grey transparent gradient for the drop shadow in the final image with the desired transparencies in place.

I'm still curious why that 2nd example up there causes an issue with it wanting a Palette, but for now it's no longer an issue.
Dmitry  
#4 Posted : Thursday, May 17, 2007 1:50:58 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,

Thanks for your post.

The 2nd code sample doesn't work because of you use 2 bitmaps: 32bppRgb and 32bppArgb. These bitmaps have no palettes so transparent item in palette cannot be used.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
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.