Re: vga_drawscansegment()

Search this archive.

From: Matan Ziv-Av (matan@svgalib.org)
Date: Sat 22 Feb 2003 - 15:44:27 IST


On Sat, 22 Feb 2003, Alper Akçan wrote:

> char buf[w * h * BYTESPERPIXEL];
> gl_getbox(x, y, w, h, buf);
> 
> When I get a buffer like that; I can use
> 
> gl_putboxpart(x, y, w, h, 1, 1, buf, 5, 5);
> to draw one pixel at (5,5) to (x,y) position. this is OK.
> 
> But what if I use vga_drawscansegment() ?
> I have tried this;
> 
> int i = ((5 * w) + 5) * BYTESPERPIXEL; // to get (5, 5) in buffer.
> vga_drawscansegment(buf, x, y, BYTESPERPIXEL); // draw (5,5) to (x,y).

You probably want buf+i, rather than buf, as the source.

I think it usually does not make sense to use those functions to draw
one pixel at a time as they have too much overhead. 

> I have also tried this;
> 
> int i = 0;
> int bufsize = w * h * BYTESPERPIXEL
> 
> gl_getbox(x, y, w, h, BYTESPERPIXEL);
> 
> while (i < bufsize) {
>   y = i / w;
>   x = i % w;
>   vga_drawscansegment(buf, x, y, BYTESPERPIXEL);
>   i += BYTESPERPIXEL;
> }

This is wrong, since i is used to count two different things - pixel
position and memory address.
Why not use vga_drawscansegment as it was meant, to draw one line at a
time?


-- 
Matan Ziv-Av.                         matan@svgalib.org



------------------------------------------------------------------
Unsubscribe:  To:   listbot@svgalib.org
              Body: unsubscribe linux-svgalib


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:25 IST