All pastes #633433 Raw Edit

Stuff

public text v1 · immutable
#633433 ·published 2007-07-25 18:04 UTC
rendered paste body
private void Init()
{
    IImagingFactory factory = (IImagingFactory)Activator.CreateInstance(Type.GetTypeFromCLSID(new
                              Guid("327ABDA8-072B-11D3-9D7B-0000F81EF32E")));

    factory.CreateImageFromFile(filePath, out imagingImage);
    backBuffer = new Bitmap(this.ClientSize.Width, this.ClientSize.Height,
                            System.Drawing.Imaging.PixelFormat.Format32bppRgb);
}

protected override void OnResize(EventArgs e)
{
    if (enableAlpha == true && this.IsDisposed == false && sizeChanged == true)
    {
        if (backBuffer != null)
            backBuffer.Dispose();

        backBuffer = new Bitmap(this.ClientSize.Width, this.ClientSize.Height,
                               System.Drawing.Imaging.PixelFormat.Format32bppRgb);

        dstRect = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height);

        if (gxBuffer != null)
        {
            gxBuffer.Dispose();
        }

        gxBuffer = Graphics.FromImage(backBuffer);
        hdcDest = gxBuffer.GetHdc();
    }
}

private void PaintAlpha(PaintEventArgs e)
{
    // Draw the background.
    gxBuffer.DrawImage(backgroundImage, 0, 0, this.Bounds, GraphicsUnit.Pixel);

    // Ask the Image object from Imaging to draw itself.
    imagingImage.Draw(hdcDest, ref dstRect, IntPtr.Zero);

    // Put the final composed image on screen.
    e.Graphics.DrawImage(backBuffer, 0, 0, dstRect, GraphicsUnit.Pixel);
}