2

I am trying to do this by adjusting the hexadecimal values of the bitmap image however as far as I can tell there is no alpha byte. Would I be able to adjust the format of the file to allow for an alpha byte or would I have to adjust the brightness by replicating an "alpha change" through the use of the rgb bytes?

Any help with regards to this would be greatly appreciated.

Thanks

dillib
  • 359
  • 1
  • 2
  • 11
  • I am not certain, but bitmap compression bitfields as alphafields only works with 16 and 32 bits. – Mykola Oct 10 '15 at 12:18
  • That's my understanding as well. This is actually for an assignment and I have to do this through the use of assembly but the wording is throwing me off because I don't understand how I can decrease the brightness of a 24-bit bitmap by a "factor of 2" when I don't know what the brightness is to begin with? Even if I do know it what is a factor of 2 decrease of 100%? – dillib Oct 10 '15 at 12:21
  • you can select you brightness scale arbitrary, than rescale it as part of the one. it mean if red has 255 gradations you may make it to 32 gradations, than rescale it by 255 * ( / 32) in that way alphafields and bitmfileds works – Mykola Oct 10 '15 at 12:28
  • 1
    lets make all picture components in 6 bits, then all picture components will have 64 gradations it means red 6 bits, green 6 bits, blue 6 bits, alpha 6 bits totaly 24 bits per pixel – Mykola Oct 10 '15 at 12:38
  • 1
    to separate components from solid 24 value use bitmasks and bitshifts – Mykola Oct 10 '15 at 12:42
  • 1
    I will look into that, thank you for your assistance – dillib Oct 10 '15 at 12:57

1 Answers1

1

Get separate color component (6 bits ber component)

#define RGBA_R(x)   (unsigned char)((x) & 0x0000003f)
#define RGBA_G(x)   (unsigned char)(((x) >> 6) & 0x0000003f)
#define RGBA_B(x)   (unsigned char)(((x) >> 12) & 0x0000003f)
#define RGBA_A(x)   (unsigned char)(((x) >> 18) & 0x0000003f)

form 24 bit color value

#define COLOR24(r, g, b, a) (((r) & 0x3f) | (((g) & 0x3f) << 6) | (((b) & 0x3f) << 12) | (((a) & 0x3f) << 18))
Mykola
  • 3,343
  • 6
  • 23
  • 39