Skip to content

Commit 5d4086d

Browse files
committed
[DW-34] optimize GetRGBBuffer by not cast Pixel to Color
1 parent 9b74625 commit 5d4086d

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • IronSoftware.Drawing/IronSoftware.Drawing.Common

IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ public byte[] GetRGBBuffer()
14591459
Span<Rgba32> pixelRow = accessor.GetRowSpan(y);
14601460
for (int x = 0; x < width; x++)
14611461
{
1462-
Color pixel = pixelRow[x];
1462+
Rgba32 pixel = pixelRow[x];
14631463
int index = (y * width + x) * 3;
14641464

14651465
rgbBuffer[index] = pixel.R;
@@ -1477,7 +1477,7 @@ public byte[] GetRGBBuffer()
14771477
Span<Rgb24> pixelRow = accessor.GetRowSpan(y);
14781478
for (int x = 0; x < width; x++)
14791479
{
1480-
Color pixel = pixelRow[x];
1480+
Rgb24 pixel = pixelRow[x];
14811481
int index = (y * width + x) * 3;
14821482

14831483
rgbBuffer[index] = pixel.R;
@@ -1495,7 +1495,7 @@ public byte[] GetRGBBuffer()
14951495
Span<Abgr32> pixelRow = accessor.GetRowSpan(y);
14961496
for (int x = 0; x < width; x++)
14971497
{
1498-
Color pixel = pixelRow[x];
1498+
Abgr32 pixel = pixelRow[x];
14991499
int index = (y * width + x) * 3;
15001500

15011501
rgbBuffer[index] = pixel.R;
@@ -1513,7 +1513,7 @@ public byte[] GetRGBBuffer()
15131513
Span<Argb32> pixelRow = accessor.GetRowSpan(y);
15141514
for (int x = 0; x < width; x++)
15151515
{
1516-
Color pixel = pixelRow[x];
1516+
Argb32 pixel = pixelRow[x];
15171517
int index = (y * width + x) * 3;
15181518

15191519
rgbBuffer[index] = pixel.R;
@@ -1531,7 +1531,7 @@ public byte[] GetRGBBuffer()
15311531
Span<Bgr24> pixelRow = accessor.GetRowSpan(y);
15321532
for (int x = 0; x < width; x++)
15331533
{
1534-
Color pixel = pixelRow[x];
1534+
Bgr24 pixel = pixelRow[x];
15351535
int index = (y * width + x) * 3;
15361536

15371537
rgbBuffer[index] = pixel.R;
@@ -1549,7 +1549,7 @@ public byte[] GetRGBBuffer()
15491549
Span<Bgra32> pixelRow = accessor.GetRowSpan(y);
15501550
for (int x = 0; x < width; x++)
15511551
{
1552-
Color pixel = pixelRow[x];
1552+
Bgra32 pixel = pixelRow[x];
15531553
int index = (y * width + x) * 3;
15541554

15551555
rgbBuffer[index] = pixel.R;
@@ -1567,7 +1567,8 @@ public byte[] GetRGBBuffer()
15671567
Span<Rgb48> pixelRow = accessor.GetRowSpan(y);
15681568
for (int x = 0; x < width; x++)
15691569
{
1570-
Color pixel = pixelRow[x];
1570+
//required casting in 16bit color
1571+
Color pixel = (Color)pixelRow[x];
15711572
int index = (y * width + x) * 3;
15721573

15731574
rgbBuffer[index] = pixel.R;
@@ -1585,7 +1586,8 @@ public byte[] GetRGBBuffer()
15851586
Span<Rgba64> pixelRow = accessor.GetRowSpan(y);
15861587
for (int x = 0; x < width; x++)
15871588
{
1588-
Color pixel = pixelRow[x];
1589+
//required casting in 16bit color
1590+
Color pixel = (Color)pixelRow[x];
15891591
int index = (y * width + x) * 3;
15901592

15911593
rgbBuffer[index] = pixel.R;
@@ -1604,7 +1606,7 @@ public byte[] GetRGBBuffer()
16041606
Span<Rgb24> pixelRow = accessor.GetRowSpan(y);
16051607
for (int x = 0; x < width; x++)
16061608
{
1607-
Color pixel = pixelRow[x];
1609+
Rgb24 pixel = pixelRow[x];
16081610
int index = (y * width + x) * 3;
16091611

16101612
rgbBuffer[index] = pixel.R;

0 commit comments

Comments
 (0)