• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

load a single png - show parts of it

 
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.
 
"The Hood"
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 ]
 
I do some of my very best work in water. Like this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!