Page 1 of 1

Characters to image?

PostPosted: Wed Apr 16, 2014 9:21 pm
by Hblade
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.

Re: Characters to image?

PostPosted: Wed Jul 16, 2014 7:37 pm
by Bee-Ant
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.