Skip to content

Commit 3ad23e8

Browse files
Use FromScaledVector4 when decoding
1 parent db1bf31 commit 3ad23e8

32 files changed

+51
-52
lines changed

src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ private void ReadRle<TPixel>(BmpCompression compression, Buffer2D<TPixel> pixels
323323
color.FromBgr24(Unsafe.As<byte, Bgr24>(ref colors[colorIdx * 4]));
324324
break;
325325
case RleSkippedPixelHandling.Transparent:
326-
color.FromVector4(Vector4.Zero);
326+
color.FromScaledVector4(Vector4.Zero);
327327
break;
328328

329329
// Default handling for skipped pixels is black (which is what System.Drawing is also doing).
330330
default:
331-
color.FromVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
331+
color.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
332332
break;
333333
}
334334
}
@@ -395,12 +395,12 @@ private void ReadRle24<TPixel>(Buffer2D<TPixel> pixels, int width, int height, b
395395
color.FromBgr24(Unsafe.As<byte, Bgr24>(ref bufferSpan[idx]));
396396
break;
397397
case RleSkippedPixelHandling.Transparent:
398-
color.FromVector4(Vector4.Zero);
398+
color.FromScaledVector4(Vector4.Zero);
399399
break;
400400

401401
// Default handling for skipped pixels is black (which is what System.Drawing is also doing).
402402
default:
403-
color.FromVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
403+
color.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
404404
break;
405405
}
406406
}
@@ -1127,7 +1127,7 @@ private void ReadRgb32BitFields<TPixel>(Buffer2D<TPixel> pixels, int width, int
11271127
g * invMaxValueGreen,
11281128
b * invMaxValueBlue,
11291129
alpha);
1130-
color.FromVector4(vector4);
1130+
color.FromScaledVector4(vector4);
11311131
}
11321132
else
11331133
{

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
3636
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3737
L16 l16 = TiffUtils.L16Default;
3838
var color = default(TPixel);
39-
color.FromVector4(TiffUtils.Vector4Default);
39+
color.FromScaledVector4(TiffUtils.Vector4Default);
4040

4141
int offset = 0;
4242
for (int y = top; y < top + height; y++)

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero24TiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
2828
// Note: due to an issue with netcore 2.1 and default values and unpredictable behavior with those,
2929
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3030
var color = default(TPixel);
31-
color.FromVector4(TiffUtils.Vector4Default);
31+
color.FromScaledVector4(TiffUtils.Vector4Default);
3232
byte[] buffer = new byte[4];
3333
int bufferStartIdx = this.isBigEndian ? 1 : 0;
3434

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
2929
// Note: due to an issue with netcore 2.1 and default values and unpredictable behavior with those,
3030
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3131
var color = default(TPixel);
32-
color.FromVector4(TiffUtils.Vector4Default);
32+
color.FromScaledVector4(TiffUtils.Vector4Default);
3333
byte[] buffer = new byte[4];
3434

3535
int offset = 0;
@@ -46,7 +46,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
4646
offset += 4;
4747

4848
var colorVector = new Vector4(intensity, intensity, intensity, 1.0f);
49-
color.FromVector4(colorVector);
49+
color.FromScaledVector4(colorVector);
5050
pixelRow[x] = color;
5151
}
5252
}
@@ -59,7 +59,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
5959
offset += 4;
6060

6161
var colorVector = new Vector4(intensity, intensity, intensity, 1.0f);
62-
color.FromVector4(colorVector);
62+
color.FromScaledVector4(colorVector);
6363
pixelRow[x] = color;
6464
}
6565
}

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32TiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
2828
// Note: due to an issue with netcore 2.1 and default values and unpredictable behavior with those,
2929
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3030
var color = default(TPixel);
31-
color.FromVector4(TiffUtils.Vector4Default);
31+
color.FromScaledVector4(TiffUtils.Vector4Default);
3232

3333
int offset = 0;
3434
for (int y = top; y < top + height; y++)

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
4040
int value = bitReader.ReadBits(this.bitsPerSample0);
4141
float intensity = value / this.factor;
4242

43-
color.FromVector4(new Vector4(intensity, intensity, intensity, 1.0f));
43+
color.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1.0f));
4444
pixelRow[x] = color;
4545
}
4646

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private static TPixel[] GeneratePalette(ushort[] colorMap, int colorCount)
5959
float r = colorMap[rOffset + i] / 65535F;
6060
float g = colorMap[gOffset + i] / 65535F;
6161
float b = colorMap[bOffset + i] / 65535F;
62-
palette[i].FromVector4(new Vector4(r, g, b, 1.0f));
62+
palette[i].FromScaledVector4(new Vector4(r, g, b, 1.0f));
6363
}
6464

6565
return palette;

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
3636
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3737
Rgba64 rgba = TiffUtils.Rgba64Default;
3838
var color = default(TPixel);
39-
color.FromVector4(TiffUtils.Vector4Default);
39+
color.FromScaledVector4(TiffUtils.Vector4Default);
4040

4141
int offset = 0;
4242

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override void Decode(IMemoryOwner<byte>[] data, Buffer2D<TPixel> pixels,
3030
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3131
Rgba64 rgba = TiffUtils.Rgba64Default;
3232
var color = default(TPixel);
33-
color.FromVector4(TiffUtils.Vector4Default);
33+
color.FromScaledVector4(TiffUtils.Vector4Default);
3434

3535
Span<byte> redData = data[0].GetSpan();
3636
Span<byte> greenData = data[1].GetSpan();

src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb242424TiffColor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, in
2828
// Note: due to an issue with netcore 2.1 and default values and unpredictable behavior with those,
2929
// we define our own defaults as a workaround. See: https://github.com/dotnet/runtime/issues/55623
3030
var color = default(TPixel);
31-
color.FromVector4(TiffUtils.Vector4Default);
31+
color.FromScaledVector4(TiffUtils.Vector4Default);
3232
int offset = 0;
3333
Span<byte> buffer = stackalloc byte[4];
3434
int bufferStartIdx = this.isBigEndian ? 1 : 0;

0 commit comments

Comments
 (0)