School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,365 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,436 people online right now. Registration is fast and FREE... Join Now!




ImageDrawText function sharpening

 

ImageDrawText function sharpening

xheartonfire43x

17 Jun, 2009 - 10:29 AM
Post #1

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 260



Thanked: 2 times
My Contributions
I have a function that I built some of and borrowed from something Ray Camden posted on his blog. It will basically take two lines of text, in my case a month and day and center it on an image.

CODE

            date_img = imageNew(img);
            //Create text variables
            img_month = UCase(dateFormat(date,"mmm"));
            img_day = dateFormat(date,"dd");
            //Add day to image
                text = img_day;
                //Create Text Layout
                buffered = ImageGetBufferedImage(date_img);
                context = buffered.getGraphics().getFontRenderContext();
                Font = createObject("java", "java.awt.Font");
                    // font name, style and size
                textFont = Font.init( "Arial", Font.BOLD, javacast("int", 13));
                textLayout = createObject("java","java.awt.font.TextLayout").init(text,textfont,context);
                //Set Text Dimensions
                textBounds = textLayout.getBounds();
                dimen.width = textBounds.getWidth();
                dimen.height = textBounds.getHeight();
                //Create Image
                attr = {font="Arial", size="13", style="bold"};
                newx = (date_img.width/2.2 - dimen.width/2.2);
                newy = (date_img.height/1.6 + dimen.height/1.6);
                imageSetDrawingColor(date_img,"white");
                imageDrawText(date_img,text,newx,newy,attr);
            //Add Month
                text = img_month;
                //Create Text Layout
                buffered = ImageGetBufferedImage(date_img);
                context = buffered.getGraphics().getFontRenderContext();
                Font = createObject("java", "java.awt.Font");
                    // font name, style and size
                textFont = Font.init( "Arial", Font.PLAIN, javacast("int", 11));
                textLayout = createObject("java","java.awt.font.TextLayout").init(text,textfont,context);
                //Set Text Dimensions
                textBounds = textLayout.getBounds();
                dimen.width = textBounds.getWidth();
                dimen.height = textBounds.getHeight();
                //Create Image
                attr = {font="Arial", size="11"};
                newx = (date_img.width/2 - dimen.width/2);
                newy = (date_img.height/2.3 + dimen.height/2.3);
                imageSetDrawingColor(date_img,"white");
                imageDrawText(date_img,text,newx,newy,attr);


The only problem that I am having is that the Arial Black text is to jagged of text. I need to sharpen it up a little bit to look more presentable. Is there another function that I could use?

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 08:44PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month