Skip to content

Commit

Permalink
Replace tabs into spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Jun 19, 2023
1 parent 1e2125d commit 45d10fd
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@ using Bitmap bmp = ProcessedImageToBitmap(image);

Bitmap ProcessedImageToBitmap(ProcessedImage rgbImage)
{
fixed (void* data = rgbImage.GetData<byte>())
{
SwapRedAndBlue(rgbImage.GetData<byte>(), rgbImage.Width, rgbImage.Height);
using Bitmap bmp = new Bitmap(rgbImage.Width, rgbImage.Height, rgbImage.Width * 3, System.Drawing.Imaging.PixelFormat.Format24bppRgb, (IntPtr)data);
return new Bitmap(bmp);
}
fixed (void* data = rgbImage.GetData<byte>())
{
SwapRedAndBlue(rgbImage.GetData<byte>(), rgbImage.Width, rgbImage.Height);
using Bitmap bmp = new Bitmap(rgbImage.Width, rgbImage.Height, rgbImage.Width * 3, System.Drawing.Imaging.PixelFormat.Format24bppRgb, (IntPtr)data);
return new Bitmap(bmp);
}
}

void SwapRedAndBlue(Span<byte> rgbData, int width, int height)
{
int totalPixels = width * height;
for (int i = 0; i < totalPixels; i++)
{
int pixelIndex = i * 3;
byte red = rgbData[pixelIndex];
byte blue = rgbData[pixelIndex + 2];

rgbData[pixelIndex] = blue;
rgbData[pixelIndex + 2] = red;
}
int totalPixels = width * height;
for (int i = 0; i < totalPixels; i++)
{
int pixelIndex = i * 3;
byte red = rgbData[pixelIndex];
byte blue = rgbData[pixelIndex + 2];

rgbData[pixelIndex] = blue;
rgbData[pixelIndex + 2] = red;
}
}
```

Expand Down

0 comments on commit 45d10fd

Please sign in to comment.