39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using LegoArtTool.Pixels;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
|
|
namespace LegoArtTool
|
|
{
|
|
public class BitmapHelperService
|
|
{
|
|
public Bitmap Scale(Bitmap bitmap, int scaleFactor)
|
|
{
|
|
var scaledBitmap = new Bitmap(bitmap.Width * scaleFactor, bitmap.Height * scaleFactor);
|
|
|
|
for (int x = 0; x < bitmap.Width; x++)
|
|
{
|
|
for (int y = 0; y < bitmap.Height; y++)
|
|
{
|
|
var sourcePixel = bitmap.GetPixel(x, y);
|
|
var sourceColor = Color.FromArgb(sourcePixel.ToArgb());
|
|
|
|
for (int scaleX = x * scaleFactor; scaleX < scaledBitmap.Width; scaleX++)
|
|
{
|
|
for (int scaleY = y * scaleFactor; scaleY < scaledBitmap.Height; scaleY++)
|
|
{
|
|
scaledBitmap.SetPixel(scaleX, scaleY, sourceColor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return scaledBitmap;
|
|
}
|
|
|
|
public Bitmap ConvertToPixelMatrix(Bitmap bitmap, List<LegoArtColorInfo> legoArtColors)
|
|
{
|
|
var pixelMatrix = new PixelMatrix(bitmap, legoArtColors);
|
|
return pixelMatrix.ConvertBitmap();
|
|
}
|
|
}
|
|
}
|