c# - Alpha value not persisting while saving Bitmap -
good morning all,
i making image steganography project college. while hiding data in image. writing "text length" int32 in pixel. int32 of 4 bytes. thought write in 4 bytes of alpha,red,green,blue, each color of 1 byte. save image in bmp format. used single stepping , data distributed , set in pixel.
the problem arise when read pixel. r,g,b have value had set them. alpha 255 no matter set.
code using distributing int32 4 bytes are
byte r, g, b, a; int colorvalue = messagelength; int first = colorvalue & 255; //r contains bit 0-7 means least significant 8 bits r = (byte)first; colorvalue = colorvalue - first; int second = colorvalue & 65535; colorvalue = colorvalue - second; second = second >> 8; //g contains 8-15 g = (byte)second; int third = colorvalue & 16777215; colorvalue = colorvalue - third; third = third >> 16; //b contains 16-23 b = (byte)third; colorvalue = colorvalue >> 24; //a contains 24-31 = (byte)colorvalue; pixelcolor = color.fromargb(a, r, g, b); bitmap.setpixel(location.x, location.y, pixelcolor);
code getting values is
byte r, g, b, a; r = pixelcolor.r; g = pixelcolor.g; b = pixelcolor.b; = pixelcolor.a; messagelength = a; messagelength = messagelength << 8; messagelength += b; messagelength = messagelength << 8; messagelength += g; messagelength = messagelength << 8; messagelength += r;
is there missing. bmp not allow alpha value persist??? please help. thanks.
sorry bitmap doesn't support alpha value.
Comments
Post a Comment