Jump to content

Noob question about DrawImage - C++


codeape
 Share

Recommended Posts

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:

  1. 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.
  2. Can I use DrawImage and keep all the colors in my image. If so are there any trade-offs?
  3. Where can I read more?

Link to comment
Share on other sites

context->SetColor(1,1,1);

 

Works biggrin.png , but why? ph34r.png

 

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

  • Upvote 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...