Page 1 of 1

Patterns, Text Paths and Text Borders

Posted: Wed Jul 29, 2009 10:17 pm
by Elenesski
I have a client who is building a simple graphical editing program for non-technically savvy sales staff to use. I am strongly considering this library because it has the best overlap of functionality. They have these requirements that I currently don't know how to implement with the library.

1) Polygon Texture Fill - This is the ability to do a polygon fill using another image as a template. Currently DrawFilledPolygon only allows me to do a fill with a specific color, and DrawTexturedLine allows me to draw with a texture, but how do I merge the two and draw the textured line within a oddly shaped polygon? Cropping only seems to work in square regions. Another way might be to draw a polygon then use it as a template, then use Get/SetPixel to eliminate pixels from the source image where it's transparent on the polygon fill image. Is there a better solution?

2) Text Path - This is the ability for the text to be drawn along a path rather than in a straight line. The best solution I can come with right now is to calculate the angles of each character in the text and draw them rotated and perpendicular according to the path. Is there a better solution?

3) Text Border - This is the ability to put a border around the individual characters. One alternative is to have them produce the fonts with the border already embedded, and eliminating this as requirement. Is there away to quickly put fixed width borders around text similar to Photoshop's Stroke Layer Style?

Re: Patterns, Text Paths and Text Borders

Posted: Thu Jul 30, 2009 3:40 am
by Elenesski
I implemented #3 with some very quick code. I don't check return codes or clean up after myself.

Code: Select all

        private void WriteColorText() {

            int ID = _Imaging.CreateNewGdPictureImage(400, 150, PixelFormat.Format24bppRgb, _Imaging.ARGB(255,255,255,255));
            _Imaging.SetTransparencyColor(ID, _Imaging.ARGB(255, 255, 255, 255));

            bool[,] Border = new bool[400,150];

            _Imaging.DrawText(ID, "Hi There", 0, 0, 49, FontStyle.FontStyleItalic, _Imaging.ARGB(0,0,0), "Times New Roman", false);

            int Copy = _Imaging.CreateClonedGdPictureImage(ID);

            for ( int X=0; X < _Imaging.GetWidth(ID); X++ ) {
                for ( int Y=0; Y < _Imaging.GetHeight(ID); Y++ ) {
                    if ( _Imaging.PixelGetColor(ID,X,Y) == _Imaging.ARGB(0,0,0) )
                        SetBorder(ref Border, X, Y, 400, 150, 2);
                }
            }
           
            for ( int X=0; X < _Imaging.GetWidth(ID); X++ ) {
                for ( int Y=0; Y < _Imaging.GetHeight(ID); Y++ ) {
                    if ( _Imaging.PixelGetColor(ID,X,Y) == _Imaging.ARGB(0,0,0) ) {
                        _Imaging.PixelSetColor(Copy, X, Y, Color.Blue);
                    } else if ( Border[X,Y] ) {
                        _Imaging.PixelSetColor(Copy, X, Y, Color.LightPink );
                    }
                        
                }
            }
           

            GdPictureStatus myResult = _Imaging.DrawGdPictureImageTransparency(Copy, _ImageID1, 1, 100, 400, 400, 200, InterpolationMode.InterpolationModeHighQualityBicubic);

            
        }

        private void SetBorder(ref bool[,] aBorder, int X, int Y, int aWidth , int aHeight , int aRadius) {
            for ( int XX = -aRadius; XX <= aRadius; XX++ ) {
                for ( int YY = -aRadius; YY <= aRadius; YY++ ) {
                    if (((X + XX) >= 0) && ((X + XX) < aWidth) && ((Y + YY) >= 0) && ((Y + YY) < aHeight)) {
                        aBorder[X + XX, Y + YY] = true;
                    }
                }
            }
            
        }

Re: Patterns, Text Paths and Text Borders

Posted: Mon Aug 03, 2009 5:20 am
by Loïc
Hi,

For 1, I think this feature will be included into the next release.

For 2, We are always considering the feasibility of this feature for the next release.

For 3: It seems that you have a good solution :wink:

Kind regards,

Loïc

Re: Patterns, Text Paths and Text Borders

Posted: Tue Aug 04, 2009 5:57 am
by Elenesski
How long before a new version is released?

Re: Patterns, Text Paths and Text Borders

Posted: Tue Aug 04, 2009 4:52 pm
by Loïc
Hi,

The next release (a major one) will be released between 17th August and 1st September 2009.

With best regards,

Loïc