Esempio n. 1
0
        unsafe void DrawStatusBar(DownloadQueueItem it, Graphics g, Rectangle posR)
        {
            //
            // Bitmap is created as 32bpp (rgb+alpha)
            //
            Bitmap status_bmp = new Bitmap(posR.Width, posR.Height,
                                           System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            System.Drawing.Imaging.BitmapData bmd = status_bmp.LockBits(
                new Rectangle(0, 0, status_bmp.Width, status_bmp.Height),
                System.Drawing.Imaging.ImageLockMode.ReadWrite,
                System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            RGB[]  item_color_line = it.ColorLine;
            byte[] modifiers       = DownloadQueueItem.Get_3D_Modifiers();

            for (int y = 0; y < bmd.Height; y++)
            {
                byte *row = (byte *)bmd.Scan0 + (y * bmd.Stride);

                for (int x = 0; x < bmd.Width; x++)
                {
                    UInt32 *pixel_ptr = (UInt32 *)(row + x * 4);
                    //row[x * 3 + 2] = 255;
                    //*pixel_ptr = 0xff0000; //RED
                    //*pixel_ptr = 0x00ff00; //GREEN
                    //*pixel_ptr = 0x1f0000ff; // BLUE
                    //*pixel_ptr = item_color_line[x] | (x << 24);
                    item_color_line[x].WriteToBuffWithModifier(pixel_ptr, modifiers[y]);
                }
            }

            status_bmp.UnlockBits(bmd);

            g.DrawImage(status_bmp, posR);
            status_bmp.Dispose();
        }