• Post Reply Bookmark Topic Watch Topic
  • New Topic

load a single png - show parts of it  RSS feed

 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is it possible to load a single png file but display specific parts of it? Consider the following "image":

What I want to do is load the image once and then display A, B, C on demand. Something like a primitive font loader.
Any ideas?
Tnx,
Tom.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you load your file into a Image, you can paint it onto a component. Once you get the Graphics object for the component, you can clip the portion of it that you want to display.
Something like:

Of course you may would want to use different clip logic for each part that you want displayed.
 
Tom Diamond
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mmmmm, I don't think that this would work. You see, distances between letters are not known at compile time. That's why there is a pink line at the top - to indicate gaps between letters. A smart program (none of the programs I have written ) would recognise the pink line and then set the clip.
Anyway, I found a more weird way to implement my font loader. I use batik to take a .ttf file, convert it to .svg then load the svg, add the desired text to it and finally display it
OK, I admit it this is a 2:00am idea but at least I get something on screen...
Tom.
[ September 08, 2003: Message edited by: Tom Diamond ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!