including bitmap figures

1 view
Skip to first unread message

Mojca Miklavec

unread,
Apr 25, 2006, 8:54:28 PM4/25/06
to gnuplot...@googlegroups.com
That's a really low-priority question: how can I "create" a bitmap
figure inside metapost (metafun)?

I get NxM tripples of numbers representing colors for each pixel (in a
C program, so I can still easily manipulate with them) and I need to
create some kind of metapost code out of it.

Of course I can "fill unitsquare withcolor ..." NxM-times, but that's
extremely inefficient. I'm attaching samples of code that produce such
images in PostScript (written very long time ago, so I should look
into specification again for details, but the main principle is to
write long strings representing colors for each pixel and then some
code has to be added before and after it; I guess that in PDF it
should be almost the same).

Thanks,
Mojca

Hans Hagen

unread,
Apr 26, 2006, 3:45:40 AM4/26/06
to gnuplot...@googlegroups.com
hm, we can cosider a simple ascii encoded bitmap resource in pdf, or alternatively write one of those portable hex bitmap formats and use a converter at runtime

no attachment anyway so i'm talking out of the blue and after all taco is the expert in that area -)

Hans


-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------

Taco Hoekwater

unread,
Apr 26, 2006, 4:01:04 AM4/26/06
to gnuplot...@googlegroups.com

Hans Hagen wrote:
>>Of course I can "fill unitsquare withcolor ..." NxM-times, but that's
>>extremely inefficient. I'm attaching samples of code that produce such
>>images in PostScript (written very long time ago, so I should look
>>into specification again for details, but the main principle is to
>>write long strings representing colors for each pixel and then some
>>code has to be added before and after it; I guess that in PDF it
>>should be almost the same).
>
> hm, we can cosider a simple ascii encoded bitmap resource in pdf, or alternatively write one of those portable hex bitmap formats and use a converter at runtime
>
> no attachment anyway so i'm talking out of the blue and after all taco is the expert in that area -)

The best approach (i guess) is to generate an hex-encoded pdf resource,
not unlike you would do for postscript level 1. That is quite doable in
metapost/TeX macros.

Generating the actual bitmap in unitsquares is a bad idea.

Cheers, Taco

Mojca Miklavec

unread,
Apr 26, 2006, 11:11:41 PM4/26/06
to gnuplot...@googlegroups.com
I'm sorry. Perhaps it was too early ;) Here's the attachment (just a
favicon from contextgarden - open the source, not [only] with gv), but
you were reading my mind anyway.

Perhaps it would make sense to write a macro like
rgbimage(16,16,"fef7f7fecfcffefefefde4e4fce4e4fefefefde8e8fefafa...")
which would encode this data into a 16x16 image (or in some arbitrary palette).

However, there's a problem somewhere else: I didn't figure out how to
test it from gnuplot. Another highly undocummented feature accepting
no "human-producible" formats.
http://gnuplot.sourceforge.net/demo_4.1/image.html (either PostScript
terminal is buggy or the figure data is corrupted on my computer).

But other features are more important than this one, this one is low-priority.

Mojca

I know. (For transformed images gnuplot does exactly that!)

Thanks,
Mojca

context.ps
Reply all
Reply to author
Forward
0 new messages