Characters to image?

Non-platform specific questions.

Characters to image?

Postby Hblade » Wed Apr 16, 2014 9:21 pm

How would I go about converting the characters of a string into separate images? For example this string: "Hello". I'd like each letter in that string to be a separate image, if possible.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Characters to image?

Postby Bee-Ant » Wed Jul 16, 2014 7:37 pm

You want to generate what kind of image?
Say you want to generate them into 20x20 image.
First of all, you need to know the ASCII code for the initial character. If you want to start from A, then it's 65 (if I'm not mistaken).

Code: Select all
void GenerateImage(char str[256], int startX, int startY)
{
    int i,j;
    for(i=0;i<strlen(str);i++)
    {
         j=(int)str[i];
         CreateActor("ImageActor", "Animation", "(none)", "(none)", startX+i*20, startY, true);
         ImageActor.animpos=j-65;
    }
}


Usage:
Code: Select all
GenerateImage("Hello", view.x+20, view.y+20);


The string should produce images depending on what image you use and their animpos.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron