(feel free to jump ahead to java specific part)
***Background***
Ok I give up!
I am designing a program to display ASCII art to represent a picture.
(Purely practice, no "real" use for such a program) but the characters I use
to represent various shades of luminous intensity have been hand picked and
are very few.
I want to "count" the number of pixels used for each of the 96? typeable
characters (I'm using courier new) and assign them a luminous intensity, in
the event of a "tie" I will apply some sort of simple algorithm which favors
the pixels being most spread out (by taking luminous intensity of the 4
quadrents of the character and applying a formula to calculate the
difference)
***Java Specific Part***
I see examples for extracting pixels from class type "Image" but I can't
seem to figure out how to generate an "Image" from a font and a text string.
Can someone point me to an example, or show me one here?
--
LTP
:)
a249@mailinator.com - 03 Mar 2007 09:57 GMT
On Mar 3, 10:08 am, "Luc The Perverse"
<sll_noSpamlicious_z_XX...@cc.usu.edu> wrote:
> I see examples for extracting pixels from class type "Image" but I can't
> seem to figure out how to generate an "Image" from a font and a text string.
> Can someone point me to an example, or show me one here?
First comes the RTFM then the perversion
Create BufferedImage
Get Graphics2D from BufferedImage
Set font on Graphics2D
Draw string on Graphics2D
Do pervert things with BufferedImage
Luc The Perverse - 03 Mar 2007 18:19 GMT
>> I see examples for extracting pixels from class type "Image" but I can't
>> seem to figure out how to generate an "Image" from a font and a text
[quoted text clipped - 8 lines]
> Draw string on Graphics2D
> Do pervert things with BufferedImage
Thanks to you and hiwa :)
I will go on my way and do my pervert things.
As for the RTFM part - do you mind answering a jeopardy style question?
This is the correct google search which would have led me to this
information. ;)
--
LTP
:)
hiwa - 03 Mar 2007 09:58 GMT
On Mar 3, 6:08 pm, "Luc The Perverse"
<sll_noSpamlicious_z_XX...@cc.usu.edu> wrote:
> (feel free to jump ahead to java specific part)
>
[quoted text clipped - 24 lines]
>
> :)
Do drawString() into an Image or BufferedImage.
Joshua Cranmer - 03 Mar 2007 19:34 GMT
> Do drawString() into an Image or BufferedImage.
Image has no drawString() method. What you mean is
image.getGraphics().drawString().
hiwa - 03 Mar 2007 23:27 GMT
> > Do drawString() into an Image or BufferedImage.
>
> Image has no drawString() method. What you mean is
> image.getGraphics().drawString().
Bah!
Mark Space - 03 Mar 2007 16:36 GMT
> I want to "count" the number of pixels used for each of the 96? typeable
> characters (I'm using courier new) and assign them a luminous intensity, in
> the event of a "tie" I will apply some sort of simple algorithm which favors
> the pixels being most spread out (by taking luminous intensity of the 4
> quadrents of the character and applying a formula to calculate the
> difference
First, what the other guys said, with regards to you original problem.
Second, though, why pick the pixels that are most "spread out?" I'd
pick the one that has the most shading where you want it, in effect
sub-sampling the text images.
For example, if you detect that a character J is lighter in the upper
left quadrant than the character K, and your original image also has a
lighter patch in the upper left in that position, why use the more
"spread out" character? Use the best match...
'course, maybe I misunderstood and you're doing this already...
Luc The Perverse - 03 Mar 2007 18:11 GMT
> For example, if you detect that a character J is lighter in the upper left
> quadrant than the character K, and your original image also has a lighter
> patch in the upper left in that position, why use the more "spread out"
> character? Use the best match...
>
> 'course, maybe I misunderstood and you're doing this already...
Currently I'm using a single character to represet a single pixel in an
image. Obviously if I get better at detecting luminous intensity inside an
ascii character I may be able to "blur" torwards other pixels or possibly
represent multiple pixels within a single ASCII character.
First thing's first :) Besides, I'm still having fun.
--
LTP
:)
Lars Enderin - 03 Mar 2007 19:37 GMT
Luc The Perverse skrev:
>> For example, if you detect that a character J is lighter in the upper left
>> quadrant than the character K, and your original image also has a lighter
[quoted text clipped - 7 lines]
> ascii character I may be able to "blur" torwards other pixels or possibly
> represent multiple pixels within a single ASCII character.
Your use of "character" is imprecise, and why do you mention ASCII? I
think you should handle bytes, not characters.
Luc The Perverse - 03 Mar 2007 23:25 GMT
> Luc The Perverse skrev:
>>> For example, if you detect that a character J is lighter in the upper
[quoted text clipped - 11 lines]
> Your use of "character" is imprecise, and why do you mention ASCII? I
> think you should handle bytes, not characters.
No point in arguing over semantics. I am now converting JPG files into
beautiful ASCII art!
Speaking of which - I believe the representing pictures using standard
characters is considered "ASCII art" even if the character set is not ASCII.
--
LTP
:)