public static void GetSpriteGlow(Image baseSprite, byte[] bgr, out byte[] pixels, bool forceHollow = false) { pixels = ImageUtil.GetPixelData((Bitmap)baseSprite); if (!forceHollow) { ImageUtil.GlowEdges(pixels, bgr, baseSprite.Width); return; } // If the image has any transparency, any derived background will bleed into it. // Need to undo any transparency values if any present. // Remove opaque pixels from original image, leaving only the glow effect pixels. var original = (byte[])pixels.Clone(); ImageUtil.SetAllUsedPixelsOpaque(pixels); ImageUtil.GlowEdges(pixels, bgr, baseSprite.Width); ImageUtil.RemovePixels(pixels, original); }
public static CGearBackground GetCGearBackground(Bitmap img) { const int Width = CGearBackground.Width; const int Height = CGearBackground.Height; if (img.Width != Width) { throw new ArgumentException($"Invalid image width. Expected {Width} pixels wide."); } if (img.Height != Height) { throw new ArgumentException($"Invalid image height. Expected {Height} pixels high."); } // get raw bytes of image byte[] data = ImageUtil.GetPixelData(img); const int bpp = 4; Debug.Assert(data.Length == Width * Height * bpp); return(CGearBackground.GetBackground(data, bpp)); }