delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/22/15:03:32

Date: Mon, 22 Dec 1997 15:01:43 -0500 (EST)
Message-Id: <199712222001.PAA10650@delorie.com>
To: DJGPP mailing list <djgpp AT delorie DOT com>
From: Alexander Bokovoy <bokovoy AT bspu DOT ac DOT by>
Subject: Re: Kinda long bitmap question...
In-Reply-To: <349ea65f.126291690@news.earthlink.net>
References: <349ea65f DOT 126291690 AT news DOT earthlink DOT net>
MIME-Version: 1.0

On Mon, 22 Dec 1997 17:47:22 GMT jaster32 AT hotmail DOT com (Jaster) wrote:

> 
> Ok.. in 320x200 graphics mode, I want to have a buffer[64000] that I
> can copy to a BITMAP * using memcpy.. for example
> 
> memcpy(bitmap->line[0],buffer,64000);
> 
> now my question is.. when I fill buffer[64000] with the int 4 and then
> memcpy it to a bitmap (320x200) that I have previously made.. instead
> of filling the whole bitmap with the color red.. it only fills
> everyother verticle line with red.. I'm not trying to use this as a
> clear_to_color() but I eventually hope to edit the buffer[64000]
> thereby being able to edit the bitmap...
If we assume that you use 256-color mode then the result of memcpy
operation was right. You should know that DJGPP's int is a 32-bit value.
So when you typed
 int buffer[64000];
you defined buffer for 4*64000 bytes. memcpy gets first 64000 bytes of
them and transfers to bitmap. In memory your int 4 get 4 bytes: 
0x04 0x00 0x00 0x00 and when you repeate it you'll have each 4th pixel
in line red and other pixels black. Of course 320/4=80 so you'll have 80
vertical lines on the screen divided by 3-pixel-wide black lines.

You should define your buffer as array of bytes and fill it with byte 4.

Alexander Bokovoy, <bokovoy AT bspu DOT ac DOT by>
---== The Soft Age coming soon ==---

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019