开发者

Draw string in canvas

开发者 https://www.devze.com 2023-01-02 20:36 出处:网络
I\'m having an hard time finding how to draw/print a String in a canvas, rotated 90º, NOT vertical letters. After some different approaches without success I was trying to follow one that would invol

I'm having an hard time finding how to draw/print a String in a canvas, rotated 90º, NOT vertical letters. After some different approaches without success I was trying to follow one that would involve printing the Graphics object to an Image object. 开发者_如何学JAVAAs the API is reduced it has been a difficult task. So basically what I'm asking you guys is if you know how to draw a String rotated 90º in a Canvas or if you don't, how can I save the graphics object to an Image one so I can follow my "hint". Thank you very much!

Guilherme


Finally, one last research in the web and here it is:

    //The text that will be displayed
    String s="java";
    //Create the blank image, specifying its size
    Image img=Image.createImage(50,50);
    //Create an instance of the image's Graphics class and draw the string to it
    Graphics gr=img.getGraphics();
    gr.drawString(s, 0, 0, Graphics.TOP|Graphics.LEFT);
    //Display the image, specifying the rotation value. For example, 90 degrees
    g.drawRegion(img, 0, 0, 50, 50, Sprite.TRANS_ROT90, 0, 0, Graphics.TOP|Graphics.LEFT);

from: http://wiki.forum.nokia.com/index.php/How_to_display_rotated_text_in_Java_ME

Thank you!

0

精彩评论

暂无评论...
验证码 换一张
取 消