コード例 #1
0
            static void Clear32Bpp(IAsyncContext context, IBitmapDataInternal bitmapData, Color32 color, int width)
            {
                int longWidth = bitmapData.RowSize >> 3;

                // writing as longs
                if (longWidth > 0)
                {
                    Color32 rawColor = bitmapData.PixelFormat switch
                    {
                        PixelFormat.Format32bppPArgb => color.ToPremultiplied(),
                        PixelFormat.Format32bppRgb => color.BlendWithBackground(bitmapData.BackColor),
                        _ => color,
                    };

                    uint argb = (uint)rawColor.ToArgb();
                    ClearRaw(context, bitmapData, longWidth, ((ulong)argb << 32) | argb);
                }

                // handling the rest (can be either the last column if width is odd, or even the whole content if RowSize is 0)
                int left = longWidth << 1;

                if (left < width && !context.IsCancellationRequested)
                {
                    ClearDirectFallback(context, bitmapData, color, left);
                }
            }
コード例 #2
0
 public override unsafe void DoSetColor32(int x, Color32 c) => ((Color32 *)Address)[x] = c.ToPremultiplied();