Logo Search packages:      
Sourcecode: gandalf version File versions

Gan_Bool gan_image_get_pix_zero ( Gan_Image img,
unsigned  row,
unsigned  col 
)

Gets a pixel from an image and compares it with zero.

Parameters:
img The image
row The row position of the pixel
col The column position of the pixel
Returns:
GAN_TRUE if the pixel is zero, GAN_FALSE otherwise.
Gets a pixel from an image and compares it with zero.
See also:
gan_image_get_pix().

Definition at line 2161 of file image_defs.c.

References Gan_RGBAPixel_d::A, Gan_RGBAPixel_f::A, Gan_RGBAPixel_ui::A, Gan_RGBAPixel_i::A, Gan_RGBAPixel_us::A, Gan_RGBAPixel_s::A, Gan_RGBAPixel_uc::A, Gan_GLAPixel_d::A, Gan_GLAPixel_f::A, Gan_GLAPixel_ui::A, Gan_GLAPixel_i::A, Gan_GLAPixel_us::A, Gan_GLAPixel_s::A, Gan_GLAPixel_uc::A, Gan_RGBAPixel_d::B, Gan_RGBAPixel_f::B, Gan_RGBAPixel_ui::B, Gan_RGBAPixel_i::B, Gan_RGBAPixel_us::B, Gan_RGBAPixel_s::B, Gan_RGBAPixel_uc::B, Gan_RGBPixel_d::B, Gan_RGBPixel_f::B, Gan_RGBPixel_ui::B, Gan_RGBPixel_i::B, Gan_RGBPixel_us::B, Gan_RGBPixel_s::B, Gan_RGBPixel_uc::B, Gan_Image::format, Gan_RGBAPixel_d::G, Gan_RGBAPixel_f::G, Gan_RGBAPixel_ui::G, Gan_RGBAPixel_i::G, Gan_RGBAPixel_us::G, Gan_RGBAPixel_s::G, Gan_RGBAPixel_uc::G, Gan_RGBPixel_d::G, Gan_RGBPixel_f::G, Gan_RGBPixel_ui::G, Gan_RGBPixel_i::G, Gan_RGBPixel_us::G, Gan_RGBPixel_s::G, Gan_RGBPixel_uc::G, GAN_BOOL, GAN_DOUBLE, gan_err_flush_trace(), gan_err_register, GAN_FALSE, GAN_FLOAT, GAN_GREY_LEVEL_ALPHA_IMAGE, GAN_GREY_LEVEL_IMAGE, GAN_INT, GAN_POINTER, GAN_RGB_COLOUR_ALPHA_IMAGE, GAN_RGB_COLOUR_IMAGE, GAN_SHORT, GAN_UCHAR, GAN_UINT, GAN_USHORT, GAN_VECTOR_FIELD_2D, Gan_GLAPixel_d::I, Gan_GLAPixel_f::I, Gan_GLAPixel_ui::I, Gan_GLAPixel_i::I, Gan_GLAPixel_us::I, Gan_GLAPixel_s::I, Gan_GLAPixel_uc::I, Gan_RGBAPixel_d::R, Gan_RGBAPixel_f::R, Gan_RGBAPixel_ui::R, Gan_RGBAPixel_i::R, Gan_RGBAPixel_us::R, Gan_RGBAPixel_s::R, Gan_RGBAPixel_uc::R, Gan_RGBPixel_d::R, Gan_RGBPixel_f::R, Gan_RGBPixel_ui::R, Gan_RGBPixel_i::R, Gan_RGBPixel_us::R, Gan_RGBPixel_s::R, Gan_RGBPixel_uc::R, Gan_Image::type, Gan_Vector3_i::x, Gan_Vector3_s::x, Gan_Vector3::x, Gan_Vector3_f::x, Gan_Vector2_i::x, Gan_Vector2_s::x, Gan_Vector2::x, Gan_Vector2_f::x, Gan_Vector3_i::y, Gan_Vector3_s::y, Gan_Vector3::y, Gan_Vector3_f::y, Gan_Vector2_i::y, Gan_Vector2_s::y, Gan_Vector2::y, Gan_Vector2_f::y, Gan_Vector3_i::z, Gan_Vector3_s::z, Gan_Vector3::z, and Gan_Vector3_f::z.

{
   switch ( img->format )
   {
      case GAN_GREY_LEVEL_IMAGE:
      switch ( img->type )
      {
         case GAN_UCHAR:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_uc ( img, row, col ) == 0 );

         case GAN_SHORT:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_s ( img, row, col ) == 0 );

         case GAN_USHORT:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_us ( img, row, col ) == 0 );

         case GAN_INT:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_i ( img, row, col ) == 0 );

         case GAN_UINT:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_ui ( img, row, col ) == 0 );

         case GAN_FLOAT:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_f ( img, row, col ) == 0.0F );

         case GAN_DOUBLE:
           return (Gan_Bool)
                  ( gan_image_get_pix_gl_d ( img, row, col ) == 0.0 );

         case GAN_BOOL:
           return (Gan_Bool)
                  ( gan_image_get_pix_b ( img, row, col ) == GAN_FALSE );

         case GAN_POINTER:
           return (Gan_Bool)
                  ( gan_image_get_pix_p ( img, row, col ) == NULL );

         default:
           gan_err_flush_trace();
           gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                              "" );
           break;
      }
      break;

      case GAN_GREY_LEVEL_ALPHA_IMAGE:
      switch ( img->type )
      {
         case GAN_UCHAR:
         {
            Gan_GLAPixel_uc pix = gan_image_get_pix_gla_uc ( img, row, col );

            return (Gan_Bool) ( pix.I == 0 && pix.A == 0 );
         }

         case GAN_SHORT:
         {
            Gan_GLAPixel_s pix = gan_image_get_pix_gla_s ( img, row, col );

            return (Gan_Bool) ( pix.I == 0 && pix.A == 0 );
         }

         case GAN_USHORT:
         {
            Gan_GLAPixel_us pix = gan_image_get_pix_gla_us ( img, row, col );

            return (Gan_Bool) ( pix.I == 0 && pix.A == 0 );
         }

         case GAN_INT:
         {
            Gan_GLAPixel_i pix = gan_image_get_pix_gla_i ( img, row, col );

            return (Gan_Bool) ( pix.I == 0 && pix.A == 0 );
         }

         case GAN_UINT:
         {
            Gan_GLAPixel_ui pix = gan_image_get_pix_gla_ui ( img, row, col );

            return (Gan_Bool) ( pix.I == 0 && pix.A == 0 );
         }

         case GAN_FLOAT:
         {
            Gan_GLAPixel_f pix = gan_image_get_pix_gla_f ( img, row, col );

            return (Gan_Bool) ( pix.I == 0.0F && pix.A == 0.0F );
         }

         case GAN_DOUBLE:
         {
            Gan_GLAPixel_d pix = gan_image_get_pix_gla_d ( img, row, col );

            return (Gan_Bool) ( pix.I == 0.0 && pix.A == 0.0 );
         }

         default:
           gan_err_flush_trace();
           gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                              "" );
           break;
      }
      break;

      case GAN_RGB_COLOUR_IMAGE:
      switch ( img->type )
      {
         case GAN_UCHAR:
         {
            Gan_RGBPixel_uc pix = gan_image_get_pix_rgb_uc ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 && pix.B == 0 );
         }

         case GAN_SHORT:
         {
            Gan_RGBPixel_s pix = gan_image_get_pix_rgb_s ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 && pix.B == 0 );
         }

         case GAN_USHORT:
         {
            Gan_RGBPixel_us pix = gan_image_get_pix_rgb_us ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 && pix.B == 0 );
         }

         case GAN_INT:
         {
            Gan_RGBPixel_i pix = gan_image_get_pix_rgb_i ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 && pix.B == 0 );
         }

         case GAN_UINT:
         {
            Gan_RGBPixel_ui pix = gan_image_get_pix_rgb_ui ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 && pix.B == 0 );
         }

         case GAN_FLOAT:
         {
            Gan_RGBPixel_f pix = gan_image_get_pix_rgb_f ( img, row, col );

            return (Gan_Bool) ( pix.R == 0.0F && pix.G == 0.0F &&
                                pix.B == 0.0F );
         }

         case GAN_DOUBLE:
         {
            Gan_RGBPixel_d pix = gan_image_get_pix_rgb_d ( img, row, col );

            return (Gan_Bool) ( pix.R == 0.0 && pix.G == 0.0 && pix.B == 0.0 );
         }

         default:
           gan_err_flush_trace();
           gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                              "" );
           break;
      }
      break;

      case GAN_RGB_COLOUR_ALPHA_IMAGE:
      switch ( img->type )
      {
         case GAN_UCHAR:
         {
            Gan_RGBAPixel_uc pix = gan_image_get_pix_rgba_uc ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 &&
                                pix.B == 0 && pix.A == 0 );
         }

         case GAN_SHORT:
         {
            Gan_RGBAPixel_s pix = gan_image_get_pix_rgba_s ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 &&
                                pix.B == 0 && pix.A == 0 );
         }

         case GAN_USHORT:
         {
            Gan_RGBAPixel_us pix = gan_image_get_pix_rgba_us ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 &&
                                pix.B == 0 && pix.A == 0 );
         }

         case GAN_INT:
         {
            Gan_RGBAPixel_i pix = gan_image_get_pix_rgba_i ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 &&
                                pix.B == 0 && pix.A == 0 );
         }

         case GAN_UINT:
         {
            Gan_RGBAPixel_ui pix = gan_image_get_pix_rgba_ui ( img, row, col );

            return (Gan_Bool) ( pix.R == 0 && pix.G == 0 &&
                                pix.B == 0 && pix.A == 0 );
         }

         case GAN_FLOAT:
         {
            Gan_RGBAPixel_f pix = gan_image_get_pix_rgba_f ( img, row, col );

            return (Gan_Bool) ( pix.R == 0.0F && pix.G == 0.0F &&
                                pix.B == 0.0F && pix.A == 0.0F );
         }

         case GAN_DOUBLE:
         {
            Gan_RGBAPixel_d pix = gan_image_get_pix_rgba_d ( img, row, col );

            return (Gan_Bool) ( pix.R == 0.0 && pix.G == 0.0 &&
                                pix.B == 0.0 && pix.A == 0 );
         }

         default:
           gan_err_flush_trace();
           gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                              "" );
           break;
      }
      break;

      case GAN_VECTOR_FIELD_2D:
      switch ( img->type )
      {
         case GAN_FLOAT:
         {
            Gan_Vector2_f pix = gan_image_get_pix_vfield2D_f ( img, row, col );

            return (Gan_Bool) ( pix.x == 0.0F && pix.y == 0.0F );
         }

         case GAN_DOUBLE:
         {
            Gan_Vector2 pix = gan_image_get_pix_vfield2D_d ( img, row, col );

            return (Gan_Bool) ( pix.x == 0.0 && pix.y == 0.0 );
         }

         case GAN_SHORT:
         {
            Gan_Vector2_s pix = gan_image_get_pix_vfield2D_s ( img, row, col );

            return (Gan_Bool) ( pix.x == 0 && pix.y == 0 );
         }

         case GAN_INT:
         {
            Gan_Vector2_i pix = gan_image_get_pix_vfield2D_i ( img, row, col );

            return (Gan_Bool) ( pix.x == 0 && pix.y == 0 );
         }

         default:
           gan_err_flush_trace();
           gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                              "" );
           break;
      }
      break;

      case GAN_VECTOR_FIELD_3D:
      switch ( img->type )
      {
         case GAN_FLOAT:
         {
            Gan_Vector3_f pix = gan_image_get_pix_vfield3D_f ( img, row, col );

            return (Gan_Bool) ( pix.x == 0.0F && pix.y == 0.0F &&
                                pix.z == 0.0F );
         }

         case GAN_DOUBLE:
         {
            Gan_Vector3 pix = gan_image_get_pix_vfield3D_d ( img, row, col );

            return (Gan_Bool) ( pix.x == 0.0 && pix.y == 0.0 && pix.z == 0.0 );
         }

         case GAN_SHORT:
         {
            Gan_Vector3_s pix = gan_image_get_pix_vfield3D_s ( img, row, col );

            return (Gan_Bool) ( pix.x == 0 && pix.y == 0 && pix.z == 0 );
         }

         case GAN_INT:
         {
            Gan_Vector3_i pix = gan_image_get_pix_vfield3D_i ( img, row, col );

            return (Gan_Bool) ( pix.x == 0 && pix.y == 0 && pix.z == 0 );
         }

         default:
           gan_err_flush_trace();
           gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                              "" );
           break;
      }
      break;

      default:
        gan_err_flush_trace();
        gan_err_register ( "gan_image_get_pix_zero", GAN_ERROR_ILLEGAL_TYPE,
                           "" );
        break;
   }

   /* shouldn't get here */
   assert(0);
   return GAN_FALSE;
}


Generated by  Doxygen 1.6.0   Back to index