Click here to Skip to main content
15,922,325 members
Home / Discussions / C#
   

C#

 
GeneralRe: Good Site Can have a look Pin
#realJSOP11-Feb-09 9:59
professional#realJSOP11-Feb-09 9:59 
Questionsong/tune comparison Pin
Vishnu Prem11-Feb-09 7:03
Vishnu Prem11-Feb-09 7:03 
AnswerRe: song/tune comparison Pin
musefan11-Feb-09 7:06
musefan11-Feb-09 7:06 
AnswerRe: song/tune comparison Pin
Alan Balkany11-Feb-09 8:24
Alan Balkany11-Feb-09 8:24 
Questionany one wokred with Casswaory linear programming. Pin
sailesh_gupta11-Feb-09 6:24
sailesh_gupta11-Feb-09 6:24 
AnswerRe: any one wokred with Casswaory linear programming. Pin
Guffa11-Feb-09 7:02
Guffa11-Feb-09 7:02 
GeneralRe: any one wokred with Casswaory linear programming. Pin
sailesh_gupta11-Feb-09 7:05
sailesh_gupta11-Feb-09 7:05 
QuestionCut a file in a specific directory and put it in another directory Pin
abbd11-Feb-09 6:05
abbd11-Feb-09 6:05 
AnswerRe: Cut a file in a specific directory and put it in another directory Pin
Giorgi Dalakishvili11-Feb-09 6:13
mentorGiorgi Dalakishvili11-Feb-09 6:13 
AnswerRe: Cut a file in a specific directory and put it in another directory Pin
musefan11-Feb-09 6:14
musefan11-Feb-09 6:14 
QuestionClass Libraries and Web References Pin
caksabre211-Feb-09 5:39
caksabre211-Feb-09 5:39 
AnswerRe: Class Libraries and Web References Pin
J4amieC11-Feb-09 5:47
J4amieC11-Feb-09 5:47 
GeneralRe: Class Libraries and Web References Pin
caksabre211-Feb-09 5:59
caksabre211-Feb-09 5:59 
QuestionTransform a file from Word to PDF and from PDF to Word Pin
abbd11-Feb-09 5:10
abbd11-Feb-09 5:10 
AnswerRe: Transform a file from Word to PDF and from PDF to Word Pin
Giorgi Dalakishvili11-Feb-09 6:17
mentorGiorgi Dalakishvili11-Feb-09 6:17 
GeneralRe: Transform a file from Word to PDF and from PDF to Word Pin
DJ-Boris11-Feb-09 6:50
DJ-Boris11-Feb-09 6:50 
GeneralRe: Transform a file from Word to PDF and from PDF to Word Pin
abbd11-Feb-09 21:11
abbd11-Feb-09 21:11 
Questionretaining alpha channels from 32bpp bmp Pin
Doof36911-Feb-09 5:01
Doof36911-Feb-09 5:01 
I am having difficulty in keeping the alpha channels in my images when I open them into a c# pictureBox.
Having spent a couple of days searching forums and things I gather that a pictureBox doesn't actually keep the alpha channel and that I need to store the info in memory and work on the data there, pre-multiplying the alpha channels and doing any other calculations I need to with the raw data and then display the result when all is done.
Unfortunately as a total noob I have no idea of how to do this.
My code so far:
Bitmap bitmap = new Bitmap(ImagePath + PBox1);
Bitmap layer = new Bitmap(ImagePath + PBox2);
                

for (int x = 0; x < layer.Width; x++)
{
    for (int y = 0; y < layer.Height; y++)
    {
        Color BitmapPixel = bitmap.GetPixel(x, y);
        Color LayerPixel = layer.GetPixel(x, y);

        int r = (LayerPixel.A * (BitmapPixel.R - LayerPixel.R)) / 256 + LayerPixel.R;
        int g = (LayerPixel.A * (BitmapPixel.G - LayerPixel.G)) / 256 + LayerPixel.G;
        int b = (LayerPixel.A * (BitmapPixel.B - LayerPixel.B)) / 256 + LayerPixel.B;
                        
        Color newColor = Color.FromArgb(r, g, b);
                        
        bitmap.SetPixel(x, y, newColor);
    }
    progressBar1.PerformStep();
    Update();
}
pictureBox3.Image = bitmap;


Basically what I want to do is take two images, both with an alpha layer in them. Overlay the second one onto the first one, using its alpha layer for transparency, and finally save out a new 32bpp image from the result.

Any help would be much appreciated.
Thankyou.
AnswerRe: retaining alpha channels from 32bpp bmp Pin
Dave Kreskowiak11-Feb-09 6:42
mveDave Kreskowiak11-Feb-09 6:42 
AnswerRe: retaining alpha channels from 32bpp bmp Pin
Guffa11-Feb-09 9:55
Guffa11-Feb-09 9:55 
AnswerRe: retaining alpha channels from 32bpp bmp Pin
Doof36912-Feb-09 4:32
Doof36912-Feb-09 4:32 
QuestionSend data from textbox to datagridview in a diferent form Pin
ZRF6911-Feb-09 3:58
ZRF6911-Feb-09 3:58 
AnswerRe: Send data from textbox to datagridview in a diferent form Pin
ByteBlocks11-Feb-09 4:09
ByteBlocks11-Feb-09 4:09 
AnswerRe: Send data from textbox to datagridview in a diferent form Pin
musefan11-Feb-09 4:16
musefan11-Feb-09 4:16 
AnswerRe: Send data from textbox to datagridview in a diferent form [modified] Pin
DaveyM6911-Feb-09 9:48
professionalDaveyM6911-Feb-09 9:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.