image_test.cc
// Creates an image with a checkerboard pattern.  For images with an alpha
// channel, the "black" pixels will actually be black (not transparent).
Creates an image with a checkerboard pattern.  For images with an alpha
channel, the "black" pixels will actually be black (not transparent).
Creates an image with a checkerboard pattern . For images with an alpha channel the " black " pixels will actually be black ( not transparent ) .
void MakeCheckerBoard(Image *image, int width, int height,
                      Image::Colorspace colorspace) {
  CHECK(image->Resize(width, height, colorspace)) << "Image resize failed";
  Color white(image->channels());
  white.SetAllChannels(255);
  Color black(image->channels());
  black.SetAllChannels(0);
  if (colorspace == Image::GRAYSCALE_PLUS_ALPHA) {
    black.SetChannel(1, 255);
  } else if (colorspace == Image::RGBA) {
    black.SetChannel(3, 255);
  }
  bool black_square = true;  
  for (int i = 0; i < image->width(); ++i) {
    for (int j = 0; j < image->height(); ++j) {
      if (black_square) {
        image->SetPixel(i, j, black);
      } else {
        image->SetPixel(i, j, white);
      }
      black_square = !black_square;
    }
    black_square = !black_square;
  }
}
void MakeCheckerBoard ( Image * image , int width , int height , Image :: Colorspace colorspace ) { CHECK ( image -> Resize ( width , height , colorspace ) ) << " " ; Color white ( image -> channels ( ) ) ; white . SetAllChannels ( 255 ) ; Color black ( image -> channels ( ) ) ; black . SetAllChannels ( 0 ) ; if ( colorspace == Image :: GRAYSCALE_PLUS_ALPHA ) { black . SetChannel ( 1 , 255 ) ; } else if ( colorspace == Image :: RGBA ) { black . SetChannel ( 3 , 255 ) ; } bool black_square = true ; for ( int i = 0 ; i < image -> width ( ) ; ++ i ) { for ( int j = 0 ; j < image -> height ( ) ; ++ j ) { if ( black_square ) { image -> SetPixel ( i , j , black ) ; } else { image -> SetPixel ( i , j , white ) ; } black_square = ! black_square ; } black_square = ! black_square ; } }
Creates an image with a checkerboard pattern.
Creates an image with a checkerboard pattern .