protected void buildRandomImageCoverThread(int _imageRowCount = 3, int _width = 40, delegate_OnImageReady _delegate = null)
{
int imageCount = _imageRowCount * _imageRowCount;
int subImageWidth = _width / _imageRowCount;
int imageWidth = _width, imageHeight = _width;
int x=1,y=1;
List<Image> imageList = this.loadRandomImagesFromDB(imageCount+1);
Image image = null;
if (imageList == null)
return;
if (imageList.Count >= imageCount)
{
Bitmap outputImage = new Bitmap(imageWidth, imageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(outputImage);
foreach(Image img in imageList)
{
graphics.DrawImage(img, x, y, subImageWidth, subImageWidth);
x += subImageWidth;
if (x >= imageWidth)
{
x = 0;
y += subImageWidth;
if (y >= imageHeight)
break;
}
}
image = (Image)outputImage;
}
if (_delegate != null) _delegate(image);
}