Jordan MacLachlan
Jordan MacLachlan

Reputation: 79

How to .setColor() as a PGM value

How can I take the values from a PGM file, set the value as the color, then use that color to fillRect()?

Upvotes: 0

Views: 51

Answers (1)

Vampire
Vampire

Reputation: 38744

I'd say the easiest is to transform the PGM color to a Java Color is using HSB to express the PGM grayscale.

new Color(Color.HSBtoRGB(0, 0, (float)actualValue/maximumValueFromPGMHeader))

Upvotes: 1

Related Questions