changing BMP file brightness using directx

Started by
4 comments, last by Guimo 18 years ago
do anyone know how to do this? what's the function related to this matter? thx:)
Advertisement
DirectX seems a bit of overkill just to brighten an image. See this article on The Code Project for information on how to write a brightness filter. It's in C#/.NET, hope you don't mind, but you didn't say what you were using. Hope it helps.

-AJ
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...
thx~i am using c++
In case you want to show the image brighter then you just need to render the bitmap using a pixel shader. You can make it dimmer or brighter as you wish.
In case you wan to save it back, D3DX has a vitmap save function which can save your backbuffer to disk.
But as said, its a little too much just for this puerpose.

Luck!
Guimo
Quote:Original post by Guimo
In case you want to show the image brighter then you just need to render the bitmap using a pixel shader. You can make it dimmer or brighter as you wish.
In case you wan to save it back, D3DX has a vitmap save function which can save your backbuffer to disk.
But as said, its a little too much just for this puerpose.

Luck!
Guimo


Would u mind give me some example on using pixel shader?
Here is a small PS for making a texture brighter:
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float2 TextureUV : TEXCOORD0; // vertex texture coords
float4 Diffuse : COLOR0; // vertex diffuse color
};

struct PS_OUTPUT
{
float4 RGBColor : COLOR0; // Pixel color
};

PS_OUTPUT BrightPS( VS_OUTPUT In )
{
PS_OUTPUT Output;
float4 value = tex2D(TextureSampler, In.TextureUV);
Output.RGBColor = value*In.Diffuse;
return Output;
}

The diffuse value comes in the VS (please dont tell me how to create a VS).
Now, you may send any brightness level you want. Say you want to double the color intensity you may send (or hardcode if you wish)
In.Diffuse = float4(2.0,2.0,2.0,2.0)

Also, if you want to dim your texture use other values like 0.5.

Luck!
Guimo


This topic is closed to new replies.

Advertisement