Skip to content

Commit

Permalink
raw bitmap: ramps
Browse files Browse the repository at this point in the history
  • Loading branch information
swharden committed Nov 8, 2022
1 parent 8800788 commit 8cad7a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions projects/bitmap-raw/BitmapGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,21 @@ public static byte[] RandomRectangles(int width = 400, int height = 300)

return bmp.GetBitmapBytes();
}

public static byte[] Ramps(int width = 401, int height = 307)
{
RawBitmap bmp = new(width, height);

for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
byte value = (byte)((x % 10) * 25);
RawColor color = RawColor.Gray(value++);
bmp.SetPixel(x, y, color);
}
}

return bmp.GetBitmapBytes();
}
}
1 change: 1 addition & 0 deletions projects/bitmap-raw/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SaveBitmapBytes(BitmapGenerator.RandomGrayscale(), "random-grayscale.jpg");
SaveBitmapBytes(BitmapGenerator.RandomRGB(), "random-rgb.jpg");
SaveBitmapBytes(BitmapGenerator.RandomRectangles(), "rectangles.jpg");
SaveBitmapBytes(BitmapGenerator.Ramps(), "ramps.jpg");

static void SaveBitmapBytes(byte[] bytes, string filename)
{
Expand Down

0 comments on commit 8cad7a1

Please sign in to comment.