private System.Drawing.Bitmap ToSystemImage(Processing.Image image, Blending2D blending = null) { if (image == null) { return(null); } System.Drawing.Bitmap converted = new Bitmap(image.Width, image.Height); if (blending == null) { blending = stdBlending; } int W_1 = converted.Width - 1; for (int y = converted.Height - 1; y >= 0; --y) { for (int x = W_1; x >= 0; --x) { float alpha = blending(x, y); int rc = (int)((float)image[x, y, 0] * alpha); int gc = (int)((float)image[x, y, 1] * alpha); int bc = (int)((float)image[x, y, 2] * alpha); int a = (int)((float)255 * alpha); converted.SetPixel(x, y, Color.FromArgb(a, rc, gc, bc)); } } return(converted); }
private Processing.Image ToProcessableImage(System.Drawing.Bitmap image) { if (image == null) { return(null); } Processing.Image converted = new Processing.Image(image.Width, image.Height, 3); int W_1 = converted.Width - 1; for (int y = converted.Height - 1; y >= 0; --y) { for (int x = W_1; x >= 0; --x) { var c = image.GetPixel(x, y); converted[x, y, 0] = c.R; converted[x, y, 1] = c.G; converted[x, y, 2] = c.B; } } return(converted); }