Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: C  |  size: 0.49 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void
  2. fillimage(unsigned char *p, int width, int height)
  3. {
  4.  int i, j;
  5.  for(i=0; i < width; i++)
  6.  {
  7.   for(j=0; j < height; j++)
  8.   {
  9.    if((i < 256)&&(j < 256))
  10.    {
  11.     *p++=rand()%256; // blue
  12.     *p++=rand()%256; // green
  13.     *p++=rand()%256; // red
  14.    } else {
  15.     *p++=i%256; // blue
  16.     *p++=j%256; // green
  17.     if(i < 256)
  18.      *p++=i%256; // red
  19.     else if(j < 256)
  20.      *p++=j%256; // red
  21.     else
  22.      *p++=(256-j)%256; // red
  23.    }
  24.    p++; /* unused byte */
  25.   }
  26.  }
  27. }