Skip to content

Commit ff49954

Browse files
committed
[DW-34] always use BmpEncoder
1 parent 2a8617d commit ff49954

File tree

1 file changed

+1
-31
lines changed
  • IronSoftware.Drawing/IronSoftware.Drawing.Common

1 file changed

+1
-31
lines changed

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

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,37 +3199,7 @@ object ICloneable.Clone()
31993199
/// <returns></returns>
32003200
private static IImageEncoder GetDefaultImageEncoder(int imageWidth, int imageHeight)
32013201
{
3202-
int threshold = 1920 * 1080; //FHD
3203-
3204-
#if NET5_0_OR_GREATER
3205-
long totalBytes = GC.GetGCMemoryInfo().TotalAvailableMemoryBytes;
3206-
long totalGB = totalBytes / (1024L * 1024 * 1024);
3207-
3208-
if (totalGB <= 2)
3209-
threshold = 1280 * 720; //HD
3210-
else if (totalGB <= 4)
3211-
threshold = 1920 * 1080; //FHD
3212-
else if (totalGB <= 8)
3213-
threshold = 2560 * 1440; //2K
3214-
else if (totalGB <= 16)
3215-
threshold = 4096 * 2160; //4K
3216-
else if (totalGB <= 32)
3217-
threshold = 7680 * 4320; //8K
3218-
else if (totalGB <= 64)
3219-
threshold = 15360 * 8640; //16K
3220-
#endif
3221-
if (imageWidth * imageHeight <= threshold)
3222-
{
3223-
//small Image
3224-
//use bmp encoder for faster operation
3225-
return new BmpEncoder { BitsPerPixel = BmpBitsPerPixel.Pixel32, SupportTransparency = true };
3226-
}
3227-
else
3228-
{
3229-
//large image
3230-
//use png encoder for less memory consumption
3231-
return new PngEncoder();
3232-
}
3202+
return new BmpEncoder { BitsPerPixel = BmpBitsPerPixel.Pixel32, SupportTransparency = true };
32333203
}
32343204

32353205
private static void InternalSaveAsMultiPageTiff(IEnumerable<Image> images, Stream stream)

0 commit comments

Comments
 (0)