Index: [thread] [date] [subject] [author]
  From: Andrew Apted <ajapted@netspace.net.au>
  To  : ggi-develop@eskimo.com
  Date: Fri, 14 May 1999 12:45:12 +1000

Re: Semi-Snag in PyGGI...

Jim Meier writes:

>  Ah, I see. Makes sense once I pull my head out of the toilet.
>  
>  Would it be a reasonable course of action to do something like the following:
>  int block_size=(number_of_pixels*actual_pixel_size_in_bytes);
>  ggi_pixel p=ggiMapColor(vis, &color);
>  ggi_pixel *pixel_buffer=(ggi_pixel*)malloc(block_size);
>  ggi_pixel *p=pixel_buffer
>  for(i=0;i<number_of_pixels;i++){
>      *pixel_buffer=p;
>      p+=actual_pixel_size_in_bytes;
>  }
>  
>  I'm thinking there's something wrong with my pointer arithmetic there.. but that's
>  a small detail to iron out.

I don't know if this will be helpful, but the following code is how the
flying_ggis demo creates the ggiPutHLine buffer (modified to use a
single ggi_pixel) :

  static uint8 translate_buffer[8192];

  static void translate_hline(int x, int y, int w, ggi_pixel p)
  {
     int ww = w;
  
     uint8  *buf1 = (uint8  *) trans_buffer;
     uint16 *buf2 = (uint16 *) trans_buffer;
     uint32 *buf4 = (uint32 *) trans_buffer;
  
     switch ((GT_SIZE(vis_mode.graphtype) + 7) / 8) {
  
     case 1:
        for (; ww > 0; ww--) {
           *buf1++ = p;
        }
        break;
  
     case 2:
        for (; ww > 0; ww--) {
           *buf2++ = p;
        }
        break;
  
     case 3:
        for (; ww > 0; ww--) {
           ggi_pixel pix = p;
  
           *buf1++ = pix; pix >>= 8;
           *buf1++ = pix; pix >>= 8;
           *buf1++ = pix;
        }
        break;
  
     case 4:
        for (; ww > 0; ww--) {
           *buf4++ = p;
        }
        break;
     }
     
     ggiPutHLine(vis, x, y, w, trans_buffer);
  }

Note case 3.  Hope that helps.

Cheers,
___________________________________________________
                                               \  /
  Andrew Apted   <ajapted@netspace.net.au>      \/
 

Index: [thread] [date] [subject] [author]