开发者

Bitmap object turns rgb(13,11,12) into rgb(211,211,211)?

Ok, this is a strange one. Huge props to the person that knows this.

I have this code, that crops part of an image, and puts it in bmpCropped.

    void CropImage()
    {
        int W = nowX - StartX;
        int H = nowY - StartY;

        if (W > 0 && H > 0)
        {
            bmpCropped = new Bitmap(W, H);
            Graphics gfxCropped = Graphics.FromImage(bmpCropped);
            gfxCropped.DrawImage(bmpOriginal, new Rectangle(0, 0, W, H), new Rectangle(StartX, StartY, W, H), GraphicsUnit.Pixel);
        }
    }

For some strange reason, all colors that have RGB values of R:13, G:11, B:12 are changed to R:211, G:211, B:211. Notic开发者_Go百科e the DrawImage? bmpCropped is drawn on the screen, where I'm not seeing the 211,211,211 at all. But if I save the image using bmpCropped.Save(...), I am seeing the 211,211,211.

Anyone has any clues on why and how this is happening, and if I can get around this problem without changing the pixel to a different color?


Sounds like you have a transparent source bitmap using a transparency key. The background color of your destination shows through the transparent pixels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜