Sign in to follow this  
gohkgohk

changing BMP file brightness using directx

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this