codeape Posted September 9, 2014 Share Posted September 9, 2014 Ok, I load a texture: mouse = Leadwerks::Texture::Load("Resources/Mousepointer/mouse.tex"); It is a png image that i have made a texture with that has DXT5 compression (the rest is Leadwerks default). I then use it: context->SetBlendMode(Leadwerks::Blend::Alpha); context->SetColor(1.0, 1.0, 1.0, 0.8); context->DrawImage(mouse, 300, 300, 16, 16); context->SetBlendMode(Leadwerks::Blend::Solid); Questions: Why does the image color change to what ever color I set with SetColor? Why does the image not keep the color it had in its orignal png file? I do not say it is wrong I only wonder why. Can I use DrawImage and keep all the colors in my image. If so are there any trade-offs? Where can I read more? Quote Link to comment Share on other sites More sharing options...
Guppy Posted September 9, 2014 Share Posted September 9, 2014 IIRC setting color to 0,0,0,0 will not tint the image Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
gamecreator Posted September 9, 2014 Share Posted September 9, 2014 Pretty sure that turns it black. The DrawImage example uses this, just before drawing: context->SetColor(1,1,1); Quote Link to comment Share on other sites More sharing options...
codeape Posted September 10, 2014 Author Share Posted September 10, 2014 IIRC setting color to 0,0,0,0 will not tint the image The image went totaly black. Pretty sure that turns it black. The DrawImage example uses this, just before drawing: context->SetColor(1,1,1); Works , but why? Quote Link to comment Share on other sites More sharing options...
whiterabbit Posted September 11, 2014 Share Posted September 11, 2014 context->SetColor(1,1,1); Works , but why? This is my basic explanation, hopefully I'm not too wrong. When the image is drawn the color of each pixel is multiplied against the color set by context->SetColor. So for example if pixel in the image is white (RGB = 255,255,255), and the context color is white (1,1,1), then they get multplied together. R := 255 x 1.0 = 255 G := 255 x 1.0 = 255 B := 255 x 1.0 = 255 If the context color was black (0,0,0) everything would be multiplied by 0: 255x0=0 If the image pixel as red (255,0,0), and the context color was 50% grey (0.5,0.5,0.5) the final color would be a darker red (127,0,0) R := 255 x 0.5 = 127 G := 0 x 0.5 = 0 B := 0 x 0.5 = 0 And the final example, the reason you would use this feature, is if your image was white you can use the context color to color the image. So, image is white (255,255,255) and say context color is orange (1,0.47,0) R := 255 x 1.0 = 255 G := 255 x 0.47 = 120 B := 255 x 0.0 = 0 1 Quote Link to comment Share on other sites More sharing options...
codeape Posted September 11, 2014 Author Share Posted September 11, 2014 Thanks whiterabbit, gamecreator and Guppy. So for example if pixel in the image is white (RGB = 255,255,255), and the context color is white (1,1,1), then they get multplied together. Hmmm that explanation works for me Quote Link to comment Share on other sites More sharing options...
codeape Posted September 11, 2014 Author Share Posted September 11, 2014 Whiterabbit i opened the drawimage.shader file today (I am learning GLSL) and I found this in the fragment shader: void main(void) { fragData0 = drawcolor * texture(texture0,vTexCoords0); } This look like what you described above 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.