rasterizing text on an image
Hello
Can anyone provide some pseudo-code on what classes and methods are necessary to put a string of text on an image? Nothing fancy, just solid black text at a fixed x,y from a corner of the image. I have Knudsen's book so I see the image and text classes, I just dont see how to combine them. Something very lightweight and proveable. Thanks for any direction.
HelloI did it by opening the file from ImageIO and generating a Graphic2D. Now my question is, how do I increase the size of the image without changing the image. I want to increase the "canvas". I cant seem to find any method to increase the size and fill with white. Ideas? tia.
Hi
I am not saying I cant change it, only that if the original is 20x20 I need to understand what classes/methods to call to make it/or a new object be say 20x60. If I cant do it inplace than how do I create a new graphics object with explicit dimensions and copy into it the original at coordinate 00? The how do I generate a BufferedImage from that? Just asking for a, non-GPS, direction, grin.
> I am not saying I cant change it
Quote: "how do I increase the size of the image without changing the image"
> If I cant do it inplace than how do I
> create a new graphics object with explicit dimensions
> and copy into it the original at coordinate 00? The
> how do I generate a BufferedImage from that?
I am still a little confused but I think you have a image that you want to make bigger. I don't mess with images like this very much but why don't you just draw the extra 20x40 extra of the image on the original? (I would have to look up the methods to do that, I am a little rusty at it.)But I think it is possible.
Z,
Yes that is what I want to do. I am less familiar than you with the methods. I assume I would do something like create a new graphics2d object of the size I want and then copy the existing one into it at 0,0. Then I would need to convert that graphics2d object into a BufferedImage so I can get it back into an ImageIO and write it out. Can anyone indicate which classes/methods are necessary for the steps above? tia.
HiI figured it out.See harassment is good for the soul, grinIt is close to what I described. I create a new BufferedImage the size I want and grab the values from the old BufferedImage. The rest should be easy. Thanks for forming the question.