Click here to Skip to main content
15,894,740 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: Send data from textbox to datagridview in a diferent form Pin
Deresen11-Feb-09 10:12
Deresen11-Feb-09 10:12 
QuestionOverride desktop context menu [modified] Pin
pmcons11-Feb-09 3:55
pmcons11-Feb-09 3:55 
AnswerRe: Override desktop context menu Pin
jas0n2311-Feb-09 4:02
jas0n2311-Feb-09 4:02 
GeneralRe: Override desktop context menu Pin
pmcons11-Feb-09 4:06
pmcons11-Feb-09 4:06 
AnswerRe: Override desktop context menu Pin
Giorgi Dalakishvili11-Feb-09 4:56
mentorGiorgi Dalakishvili11-Feb-09 4:56 
GeneralRe: Override desktop context menu Pin
pmcons11-Feb-09 5:31
pmcons11-Feb-09 5:31 
QuestionA New Language In C# Pin
jas0n2311-Feb-09 3:50
jas0n2311-Feb-09 3:50 
AnswerRe: A New Language In C# Pin
musefan11-Feb-09 4:11
musefan11-Feb-09 4:11 
AnswerRe: A New Language In C# Pin
Pete O'Hanlon11-Feb-09 4:29
mvePete O'Hanlon11-Feb-09 4:29 
AnswerRe: A New Language In C# Pin
riced11-Feb-09 4:46
riced11-Feb-09 4:46 

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.