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:10:21 PM(UTC)
Crimblepud

Rank: Member

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

I seem to be having a problem using the DrawText & DrawArtisticText methods.
I am trying to create a text effect similar to Glow/Shadow using both these methods, but the text drawn by the DrawArtisticText method seems to be drawn out of sync with the text drawn by the DrawText method.
As you look along the text going from left to right the DrawArtisticText text seems to be rendered narrower overall.
You can see what I mean by looking at the ASP code below & the attatched image.
Does anyone have any idea on how to resolve this? Is It a bug? Any help gratefully received.


Code:
<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Option Explicit
Response.Buffer = true

Dim strString
strString = "Text Is Text Is Text Is Text Is Text"

' Create the Bitmap object...
Dim objBitmap
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
objBitmap.ApplyInPlace = true

' Create bitmap with transparent background...
objBitmap.CreateNew 600, 150, Format32bppPArgb, &hFFDDFFDD&

' 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 = 36
	'.TextFormat.HorizontalAlignment = HorizontalAlignmentCenter
	'.TextFormat.VerticalAlignment = VerticalAlignmentBottom
	
	' Text to be drawn with X/Y co-ordinates...
	.Unit = UnitPixel

	.Brush.PrimaryColor = .Color.CreateRGB(64, 57, 161)
	.Pen.ForeColor = .Color.CreateRGB(211, 209, 233)
	.Pen.Weight = 4.5
	.DrawArtisticText strString, 10, 10, true, true

	.DrawText strString, 10, 10

End With

' Save image to response stream (e.g. draw to page)...
objBitmap.SaveToStream Response

Set objBitmap = Nothing

%>


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

Crimblepud attached the following image(s):
prep_test_image.png
Andrew  
#2 Posted : Wednesday, May 31, 2006 11:18:41 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)
I run your code and it works fine for me (see the attachment). Are you sure that the image in your attach was generated with the same code?
Andrew attached the following image(s):
artistic.asp.png
Crimblepud  
#3 Posted : Thursday, June 1, 2006 12:15:42 AM(UTC)
Crimblepud

Rank: Member

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

It is the same code - just double-checked. And my manager has too.
Any chance you can check the font details at your end?
Double-clicking on my copy of the font gives the following:

Impress BT (TrueType)
Typeface name: Impress BT
File size: 60 KB
Version: mfgpctt-v1.27 Thursday, March 26, 1992 3:53:22 pm (EST)
Copyright 1990-1992 Bitstream Inc. Allrights reserved.

Could it be because of a difference in DLL versions, or something to do with the PC hardware itself?

John
Crimblepud  
#4 Posted : Thursday, June 1, 2006 5:24:21 PM(UTC)
Crimblepud

Rank: Member

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

Just to follow up we have tried this on at least 6 different machines all with differing processors, RAM, graphics cards, etc. And a mixture of Windows 2000 Workstation/Servers, and XP Professional.
All give similar results to the first image I posted, and not once have we been able to achive a result similar to the image you posted.
I created a new bit of code (see below) for this test, and have attatched a gif image that shows the output on one of the machines.
This is a big issue for us, so hope that you and the developers can help.
Regards,
John


ASP CODE USED TO GENERATE GIF IMAGE:

Code:
<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Option Explicit

Dim arrFonts, strString, i
arrFonts = Array("Impress BT", "Arial", "Book Antiqua", "Bookman Old Style", "Century", "Century Gothic", _
	 "Comic Sans MS", "Courier New", "Garamond", "Georgia", "Haettenschweiler", "Impact", "Lucinda Console", _
	 "Microsoft Sans Serif Regular", "Palatino Linotype", "Symbol", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana")

strString = ": Text Is Text Is Text Is Text Is Text Is Text"

Dim objBitmap
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
objBitmap.ApplyInPlace = true
objBitmap.CreateNew 900, 600, Format32bppPArgb, &hFFDDFFDD

With objBitmap.Graphics 
	.Engine = DrawingEngineGdiplus
	.Antialiasing = true
	.Unit = UnitPoint
	.TextFormat.FontColor = .Color.CreateRGB(73, 1, 73)
	.TextFormat.FontSize = 24

	.Unit = UnitPixel
	.Brush.PrimaryColor = .Color.CreateRGB(64, 57, 161)
	.Pen.ForeColor = .Color.CreateRGB(211, 209, 233)
	.Pen.Weight = 4.5
	
	For i = 0 To UBound(arrFonts)
		.TextFormat.FontName = arrFonts(i)
		.DrawArtisticText arrFonts(i) & strString, 10, (i * 30), true, true
		.DrawText arrFonts(i) & strString, 10, (i * 30)
	Next 'i
	
End With

objBitmap.Data.ConvertTo24bppRgb True, ColorWhite

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

objBitmap.SaveToStream Response
Set objBitmap = Nothing
%>

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

Crimblepud attached the following image(s):
GraphicsMill_test.gif
Andrew  
#5 Posted : Sunday, June 4, 2006 4:31:45 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)
I tried your code and got similar problems with certain fonts (altough now with all of them as in your case). After some investigations I found out that GDI+ returns a bit different font metrics and amount of space added before and after glyphs differs from ABC values returned by GDI.

So I have written small DrawString function which draws specific character on specific position, and therefore there is a control on characters layout. It can use both DrawText and DrawArtisticText, so you can use it in your code to draw these lines together.

Code:
Sub DrawString(objBitmap, IsArtistic, strText, X, Y, IsFilled, IsOutlined)
  Dim I, arrPositions
  With objBitmap.Graphics
    arrPositions = .TextFormat.GetCharacterPositions(strText, X)
    Dim CurrentChar
    For I = LBound(arrPositions) To UBound(arrPositions) 
       CurrentChar = Mid(strText, I + 1, 1)
       If CurrentChar<>" " Then
         If IsArtistic Then
           .DrawArtisticText CurrentChar, arrPositions(I) + .TextFormat.Abc(CurrentChar, 0), Y, IsFilled, IsOutlined 
         Else
           .DrawText CurrentChar, arrPositions(I), Y
         End If
       End If
    Next
  End With
End Sub


Usage:

Code:
Dim strText
For i = 0 To UBound(arrFonts)
strText = arrFonts(i) & strString
.TextFormat.FontName = arrFonts(i)

'Artistic text; last four parameters are the same as in DrawArtisticText
[b]DrawString objBitmap, true, strText, 10, (i * 30), true, true[/b]

'Common  DrawText; last two parameters are disregarded. 
DrawString objBitmap, false, strText, 10, (i * 30), false, true

Next 'i


Just in case, download latest DLLs.

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

Crimblepud  
#6 Posted : Sunday, June 4, 2006 7:22:35 PM(UTC)
Crimblepud

Rank: Member

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

Hi
Thanks for your reply.
1: Download & installed the DLLs from the link you provided, but there is no change to the output of the code detailed in my previous post.
2: I had already tried something very similar to the code you suggested, and it produces the same output as yours. While it works for this example, it does not if you want to centre the text, using
.TextFormat.HorizontalAlignment = HorizontalAlignmentCenter
But for the time being, I will write a bit of code to set the centre position manually to hopefully get around this.
3: I would like to know if there is any chance that this bug, and the bug I mentioned in another post (Topic3628-3-1.aspx) will be fixed any time soon, as I notice that it seems to be some time since the last version of the main DLL was released. And also the workarounds add to the load time, processing, etc. for the ASP pages involved.
4: I am still intrigued as to how you produced your image that displays the text using Impress BT font, with the text unaffected. Can you confirm that the font proerties are the same as detailed in the post above?
Regards,
John Campbell
Andrew  
#7 Posted : Sunday, June 4, 2006 11:55:12 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)
Quote:
3: I would like to know if there is any chance that this bug, and the bug I mentioned in another post (Topic3628-3-1.aspx) will be fixed any time soon, as I notice that it seems to be some time since the last version of the main DLL was released. And also the workarounds add to the load time, processing, etc. for the ASP pages involved.


I have submitted all problems to developers. When we will have some time, we will take a look into it. Meantwhile the only way is to use these workarounds...

Quote:
4: I am still intrigued as to how you produced your image that displays the text using Impress BT font, with the text unaffected. Can you confirm that the font proerties are the same as detailed in the post above?


The font is the same as you sent me (see the screenshot in attachment). I just copied your code again to double-check it and it worked fine...
Andrew attached the following image(s):
font_impress_bt_screenshot.PNG
Andrew  
#8 Posted : Monday, June 5, 2006 12:08:27 AM(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)
BTW, why not to use DrawArtisticText twice instead of DrawText over DrawArtisticText? Like this:

Code:
.DrawArtisticText strText,  10, (i * 30), false, true
.DrawArtisticText strText,  10, (i * 30), true, false


In this case you should not have to implement your own draw text function.

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

Crimblepud  
#9 Posted : Monday, June 5, 2006 7:06:45 PM(UTC)
Crimblepud

Rank: Member

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

What is the method ".TextFormat.Abc()" that you mention in your example code above?
I can find no mention of it in the help file.
Thanks,
John
Andrew  
#10 Posted : Tuesday, June 6, 2006 1:43:40 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)
This property returns A, B, or C metric for specified character or string. This quote from MSDN explains what is ABC metrics:

Quote:
The TrueType rasterizer provides ABC character spacing after a specific point size has been selected. A spacing is the distance added to the current position before placing the glyph. B spacing is the width of the black part of the glyph. C spacing is the distance added to the current position to provide white space to the right of the glyph. The total advanced width is specified by A+B+C.

http://msdn.microsoft.com/libra...-us/gdi/fontext_8icz.asp

First argument is a string, the second one - member of enumeration that specifies whether you need to get A, B, or C:
  • AbcMetricA=0
  • AbcMetricB=1
  • AbcMetricC=2
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.