9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Q: libdraw, loadimage, allocimage
@ 2003-10-21  9:04 a.b
  2003-10-21 14:21 ` mirtchov
  0 siblings, 1 reply; 3+ messages in thread
From: a.b @ 2003-10-21  9:04 UTC (permalink / raw)
  To: 9fans

hi!

could anyone, please, help me?

i have no problem with line, fillelipse, bezier and so on.
but i can't put bitmap image onto screen. i red man, draw.h, faces,
but my code is not working. 
could you show me the solution for this code:

uchar bitmap[]={0xff,0x00.......}    /* CMAP8 image */
image=allocimage("help me here!");
loadimage(image,bitmap,sizeof(bitmap),"help me here!");
draw("help me here!");

thank everyone for help :-)
Sasa Babic (a.b@email.cz)


________________________________________________________________________________
Aktuálně: Soutěžte o sušičku prádla Ariston A 46 C s Obchodním domem.cz na http://www.email.cz/obchodnidum




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Q: libdraw, loadimage, allocimage
  2003-10-21  9:04 [9fans] Q: libdraw, loadimage, allocimage a.b
@ 2003-10-21 14:21 ` mirtchov
  2003-10-22  1:22   ` okamoto
  0 siblings, 1 reply; 3+ messages in thread
From: mirtchov @ 2003-10-21 14:21 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]


I had a long winded reply which died with my drawterm,
unfortunately...

Anyway, take a look at the example I've attached here, and also at the
xscr hacks:

	http://pages.cpsc.ucalgary.ca/~mirtchov/p9/xscr/xscr.tar.gz

The key with loadimage() is to avoid using it if possible -- it
circumvents optimizations in the draw() design by loading data over
the network all the time.  Very slow over slow networks.

Compare for example 'eruption', which does 'loadimage' for the entire
display, rd-bomb, which does loadimage of a 256x256 bitmap, and
polyominoes, which uses pre-allocated color palette stored on the
display machine and see which one is faster...

andrey

[-- Attachment #2: bmap.c --]
[-- Type: text/plain, Size: 983 bytes --]

#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>

void
eresized(int new)
{
	USED(new);
	exits("done");
}

void
main(int argc, char **argv)
{
	Image *img;
	Mouse m;
	uchar bmp[256];
	ulong tick = 0;
	int i;

	USED(argc, argv);

	if(initdraw(nil, nil, "bmap") < 0)
		sysfatal("initdraw failed: %r");

	einit(Emouse);

	img = allocimage(display, Rect(0, 0, 16, 16), CMAP8, 1, DCyan);
	if(img == nil)
		sysfatal("cannot allocate image: %r\n");

	/* set so it replicates over the entire window */
	replclipr(img, 1, Rect(0, 0, Dx(screen->r), Dy(screen->r)));

	for(;;) {
		for(i = 0; i < 256; i++)
			bmp[i] = tick++;
		tick++;

		/* fill it up with whatever is in bitmap */
		loadimage(img, Rect(0, 0, 16, 16), bmp, 16*16);

		/* draw it over the entire screen */
		draw(screen, screen->r, img, nil, ZP);

		flushimage(display, 1);

		if(ecanmouse()) {
			m = emouse();
			if(m.buttons)
					exits(0);
		}
	}

}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Q: libdraw, loadimage, allocimage
  2003-10-21 14:21 ` mirtchov
@ 2003-10-22  1:22   ` okamoto
  0 siblings, 0 replies; 3+ messages in thread
From: okamoto @ 2003-10-22  1:22 UTC (permalink / raw)
  To: 9fans

> Compare for example 'eruption', which does 'loadimage' for the entire
> display, rd-bomb, which does loadimage of a 256x256 bitmap, and
> polyominoes, which uses pre-allocated color palette stored on the
> display machine and see which one is faster...

or try
http://basalt.cias.osakafu-u.ac.jp/plan9/plumb.tgz

This is a games/plumb.☺

Kenji



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-22  1:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-21  9:04 [9fans] Q: libdraw, loadimage, allocimage a.b
2003-10-21 14:21 ` mirtchov
2003-10-22  1:22   ` okamoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).