[I study here]
Regards, Fiò
Fiorenza Oppici wrote:so, let me understand, your question is how to create a new color instance using both the old color info and the new alpha value, or it's more a problem regarding code for doing that? : )
Brendan Jones wrote:
Fiorenza Oppici wrote:so, let me understand, your question is how to create a new color instance using both the old color info and the new alpha value, or it's more a problem regarding code for doing that? : )
My question is how would I go about getting the value of the new color. I have no problem actually setting the pixel color and then drawing the image to the screen, I just don't know how to implement transparency into the pixels.
[I study here]
Regards, Fiò
Fiorenza Oppici wrote:
Brendan Jones wrote:
Fiorenza Oppici wrote:so, let me understand, your question is how to create a new color instance using both the old color info and the new alpha value, or it's more a problem regarding code for doing that? : )
My question is how would I go about getting the value of the new color. I have no problem actually setting the pixel color and then drawing the image to the screen, I just don't know how to implement transparency into the pixels.
as far as i know the int oldColor contains the info for red component in bits 16-23, for green component in bits 8-15 and for the blue ones in bits 0-7, as the Javadoc says.
so, you can get from that single int three other ints red, green, and blue truncating the bits and then shift divide each chunk with the right weight, so then you can instanciate the Color e.g "newcolor" with the constructor (int red, int g, int b, int alpha).
all this work can be done simply calling the Color methods getGreen(), getRed() e getBlue(). I'm not comfortable with shifting so I'd go for this option.
but you already used shifting and bitwise operations in your below code, so you can do the first way.
maybe someone can be more explicative on the exact code for converting the int into separate components, i found some examples on the web but I never suggest something it's not my own code... however, I hope i've been hepful.![]()
[I study here]
Regards, Fiò
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |