Product Engineer, CTO & a Beer Enthusiast
Experiments, thoughts and scripts documented for posterity.
March 19, 2018
Point end = new Point(area.X + area.Width, area.Y + area.Height); for (int x = area.X = 0; x < end.X; x += quality) { for (int y = area.Y; y < end.Y; y += quality) { c = bmp.GetPixel(x, y); r += c.R; g += c.G; b += c.B; p++; } } return Color.FromArgb(255, (int)(r / p), (int)(g / p), (int)(b / p));
public class MosaicTile { public int X { get; set; } public int Y { get; set; } public string ImageFileName { get; set; } }Upon page load, the browser builds a table/grid and places the image in the appropriate location (x,y) to make it look like a single mosaic. As a side note, since the browser displays 100's of images for the mosaic, this potentially could lead to memory build up on the browser. This can be handled by using revokeObjectURL method. Code snippet:
$('img').load(function () { window.URL.revokeObjectURL($(this).attr('src')); });
Library for generating image mosaic in c# can be found at my github repo : https://github.com/karthik20522/ImageMosaic