PNG Incomplete reads : Amask is 0x00000000,SDL_image

Ok as advised i checked the alpha mask using :-

//Loads textures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator

  SDL_Surface* TextureImage[1];                      // Create Storage Space For The Texture

  memset(TextureImage,0,sizeof(void  *)*1);                // Set The Pointer To NULL

  // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
  if (TextureImage[0]=load_image("Data/glass.png"))
  {
      Status=TRUE;                                       // Set The Status To TRUE

      glGenTextures(3,  &texture[0]);                     // Create  Three Textures

      printf("\nwidth = %d", TextureImage[0]->w);
      printf("\nA = %p", TextureImage[0]->format->Amask);
      printf("\nR = %p", TextureImage[0]->format->Rmask);
      printf("\nG = %p", TextureImage[0]->format->Gmask);
      printf("\nB = %p", TextureImage[0]->format->Bmask);
      
      
      // Create Linear Filtered Texture
      glBindTexture(GL_TEXTURE_2D, texture[1]);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
      glTexImage2D(GL_TEXTURE_2D, 0, 4,  TextureImage[0]->w, TextureImage[0]->h, 0, GL_BGRA_EXT,  GL_UNSIGNED_BYTE, TextureImage[0]->pixels);

      // Create MipMapped Texture
      glBindTexture(GL_TEXTURE_2D, texture[2]);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
      gluBuild2DMipmaps(GL_TEXTURE_2D,  3, TextureImage[0]->w, TextureImage[0]->h, GL_RGB,  GL_UNSIGNED_BYTE, TextureImage[0]->pixels);
  }

  if (TextureImage[0])                                   // If Texture Exists
  {
       SDL_FreeSurface(TextureImage[0]);                 // Free The Texture Image Memory
                                    
  }
  
  glMatrixMode(GL_TEXTURE);
  glScalef(1.0f, -1.0f, 1.0f);
  glMatrixMode(GL_MODELVIEW);

  return Status;                                           // Return The Status

}

The output is as follows:-
A = 00000000
R = 000000FF
G = 0000FF00
B = 00FF0000

But when i do this i get what i expect

#define RMASK 0x00FF0000
#define GMASK 0x0000FF00
#define BMASK 0x000000FF
#define AMASK 0xFF000000

unsigned int img[32*32];
for (i = 0; i < 32; i++)
for (int j = 0; j < 16; j++){
//printf("\nimg: =%d",(unsigned int)img[i][j]);
img[i*32+j]=0x80FF0000; //set alpha
img[i*32+j+16]=0x45FF0000; //set alpha
}

SDL_Surface* imgsurf;

imgsurf=SDL_CreateRGBSurfaceFrom( img, 32, 32, 32, 4*32, RMASK, GMASK, BMASK, AMASK );
glTexImage2D(GL_TEXTURE_2D, 0, 4, imgsurf->w, imgsurf->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, imgsurf->pixels);

Here i set up the above image data & set the alpha so that the right half is more transparent than left.I create an BGRA surface & create the texture & everything works fine. The masks are now read as i expect:-

A = FF000000
R = 00FF0000
G = 0000FF00
B = 000000FF

Abhijit---------------------------------
See the all-new, redesigned Yahoo.com. Check it out.

Sub PNG Incomplete reads:Amask is 0x00000000,SDL_image

Ok as advised i checked the alpha mask using :-

//Loads textures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator

  SDL_Surface* TextureImage[1];                      // Create Storage Space For The Texture

  memset(TextureImage,0,sizeof(void  *)*1);                // Set The Pointer To NULL

  // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
  if (TextureImage[0]=load_image("Data/glass.png"))
  {
      Status=TRUE;                                       // Set The Status To TRUE

      glGenTextures(3,  &texture[0]);                     // Create Three Textures

      printf("\nwidth = %d", TextureImage[0]->w);
      printf("\nA = %p", TextureImage[0]->format->Amask);
      printf("\nR = %p", TextureImage[0]->format->Rmask);
      printf("\nG = %p", TextureImage[0]->format->Gmask);
      printf("\nB = %p", TextureImage[0]->format->Bmask);
      
      
      // Create Linear Filtered Texture
      glBindTexture(GL_TEXTURE_2D, texture[1]);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
      glTexImage2D(GL_TEXTURE_2D, 0, 4,  TextureImage[0]->w, TextureImage[0]->h, 0, GL_BGRA_EXT,  GL_UNSIGNED_BYTE, TextureImage[0]->pixels);

      // Create MipMapped Texture
      glBindTexture(GL_TEXTURE_2D, texture[2]);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
      gluBuild2DMipmaps(GL_TEXTURE_2D,  3, TextureImage[0]->w, TextureImage[0]->h, GL_RGB,  GL_UNSIGNED_BYTE, TextureImage[0]->pixels);
  }

  if (TextureImage[0])                                  // If  Texture Exists
  {
       SDL_FreeSurface(TextureImage[0]);                 // Free The Texture Image  Memory
                                    
  }
  
  glMatrixMode(GL_TEXTURE);
  glScalef(1.0f, -1.0f, 1.0f);
  glMatrixMode(GL_MODELVIEW);

  return Status;                                           // Return The Status

}

The output is as follows:-
A = 00000000
R = 000000FF
G = 0000FF00
B = 00FF0000

But when i do this i get what i expect

#define RMASK 0x00FF0000
#define GMASK 0x0000FF00
#define BMASK 0x000000FF
#define AMASK 0xFF000000

unsigned int img[32*32];
for (i = 0; i < 32; i++)
for (int j = 0; j < 16; j++){
//printf("\nimg: =%d",(unsigned int)img[i][j]);
img[i*32+j]=0x80FF0000; //set alpha
img[i*32+j+16]=0x45FF0000; //set alpha
}

SDL_Surface* imgsurf;

imgsurf=SDL_CreateRGBSurfaceFrom( img, 32, 32, 32, 4*32, RMASK, GMASK, BMASK, AMASK );
glTexImage2D(GL_TEXTURE_2D, 0, 4, imgsurf->w, imgsurf->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, imgsurf->pixels);

Here i set up the above image data & set the alpha so that the right half is more transparent than left.I create an BGRA surface & create the texture & everything works fine. The masks are now read as i expect:-

A = FF000000
R = 00FF0000
G = 0000FF00
B = 000000FF

It seems SDL_image does not read PER PIXEL ALPHA!!

Abhijit---------------------------------
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta.