mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-05 06:30:36 +12:00
fixed #111: Using 32bppArgb everywhere
This commit is contained in:
parent
93f77f5fa1
commit
5bb526f0d1
|
@ -47,7 +47,7 @@ public static class ColorMatrixManager
|
|||
|
||||
public static Image Apply(this ColorMatrix matrix, Image img)
|
||||
{
|
||||
Bitmap dest = img.CreateEmptyBitmap(PixelFormat.Format32bppArgb);
|
||||
Bitmap dest = img.CreateEmptyBitmap();
|
||||
Rectangle destRect = new Rectangle(0, 0, dest.Width, dest.Height);
|
||||
return Apply(matrix, img, dest, destRect);
|
||||
}
|
||||
|
|
|
@ -481,19 +481,13 @@ public static void MoveDown(this ListViewItem lvi)
|
|||
lvi.Selected = true;
|
||||
}
|
||||
|
||||
public static Bitmap CreateEmptyBitmap(this Image img, int widthOffset = 0, int heightOffset = 0, PixelFormat pixelFormat = PixelFormat.Undefined)
|
||||
public static Bitmap CreateEmptyBitmap(this Image img, int widthOffset = 0, int heightOffset = 0, PixelFormat pixelFormat = PixelFormat.Format32bppArgb)
|
||||
{
|
||||
if (pixelFormat == PixelFormat.Undefined) pixelFormat = img.PixelFormat;
|
||||
Bitmap bmp = new Bitmap(img.Width + widthOffset, img.Height + heightOffset, pixelFormat);
|
||||
bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
public static Bitmap CreateEmptyBitmap(this Image img, PixelFormat pixelFormat)
|
||||
{
|
||||
return CreateEmptyBitmap(img, 0, 0, pixelFormat);
|
||||
}
|
||||
|
||||
public static float Remap(this float value, float from1, float to1, float from2, float to2)
|
||||
{
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
|
|
|
@ -81,7 +81,7 @@ public static Image ResizeImage(Image img, int width, int height)
|
|||
return img;
|
||||
}
|
||||
|
||||
Bitmap bmp = new Bitmap(width, height, img.PixelFormat);
|
||||
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution);
|
||||
|
||||
using (img)
|
||||
|
@ -154,7 +154,7 @@ public static Image ResizeImage(Image img, int width, int height, bool allowEnla
|
|||
newY += (int)((height - (img.Height * ratio)) / 2);
|
||||
}
|
||||
|
||||
Bitmap bmp = new Bitmap(width, height, img.PixelFormat);
|
||||
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
bmp.SetResolution(img.HorizontalResolution, img.VerticalResolution);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
|
@ -260,7 +260,7 @@ public static Image DrawOutline(Image img, GraphicsPath gp)
|
|||
|
||||
public static Bitmap AddSkew(Image img, int x, int y)
|
||||
{
|
||||
Bitmap result = img.CreateEmptyBitmap(Math.Abs(x), Math.Abs(y), PixelFormat.Format32bppArgb);
|
||||
Bitmap result = img.CreateEmptyBitmap(Math.Abs(x), Math.Abs(y));
|
||||
|
||||
using (Graphics g = Graphics.FromImage(result))
|
||||
using (img)
|
||||
|
@ -279,7 +279,7 @@ public static Bitmap AddSkew(Image img, int x, int y)
|
|||
|
||||
public static Image AddCanvas(Image img, Padding margin)
|
||||
{
|
||||
Bitmap bmp = img.CreateEmptyBitmap(margin.Horizontal, margin.Vertical, PixelFormat.Format32bppArgb);
|
||||
Bitmap bmp = img.CreateEmptyBitmap(margin.Horizontal, margin.Vertical);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
using (img)
|
||||
|
@ -393,7 +393,7 @@ public static Image DrawBorder(Image img, Pen borderPen, BorderType borderType)
|
|||
else
|
||||
{
|
||||
int borderSize = (int)borderPen.Width;
|
||||
bmp = img.CreateEmptyBitmap(borderSize * 2, borderSize * 2, PixelFormat.Format32bppArgb);
|
||||
bmp = img.CreateEmptyBitmap(borderSize * 2, borderSize * 2);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
using (img)
|
||||
|
@ -425,7 +425,7 @@ public static Bitmap FillBackground(Image img, Color fromColor, Color toColor, L
|
|||
|
||||
public static Bitmap FillBackground(Image img, Brush brush)
|
||||
{
|
||||
Bitmap result = img.CreateEmptyBitmap(PixelFormat.Format32bppArgb);
|
||||
Bitmap result = img.CreateEmptyBitmap();
|
||||
|
||||
using (Graphics g = Graphics.FromImage(result))
|
||||
using (img)
|
||||
|
@ -445,7 +445,7 @@ public static Image DrawCheckers(Image img)
|
|||
|
||||
public static Image DrawCheckers(Image img, int size, Color color1, Color color2)
|
||||
{
|
||||
Bitmap bmp = img.CreateEmptyBitmap(PixelFormat.Format32bppArgb);
|
||||
Bitmap bmp = img.CreateEmptyBitmap();
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
using (Image checker = CreateCheckers(size, color1, color2))
|
||||
|
@ -704,7 +704,7 @@ public static Bitmap AddShadow(Image sourceImage, float opacity, int size, float
|
|||
|
||||
try
|
||||
{
|
||||
shadowImage = sourceImage.CreateEmptyBitmap(size * 2, size * 2, PixelFormat.Format32bppArgb);
|
||||
shadowImage = sourceImage.CreateEmptyBitmap(size * 2, size * 2);
|
||||
|
||||
ColorMatrix maskMatrix = new ColorMatrix();
|
||||
maskMatrix.Matrix00 = 0;
|
||||
|
@ -816,7 +816,7 @@ public static Bitmap Pixelate(Bitmap sourceImage, int pixelSize)
|
|||
|
||||
public static Image CreateTornEdge(Image sourceImage, int toothHeight, int horizontalToothRange, int verticalToothRange, AnchorStyles sides)
|
||||
{
|
||||
Image result = sourceImage.CreateEmptyBitmap(PixelFormat.Format32bppArgb);
|
||||
Image result = sourceImage.CreateEmptyBitmap();
|
||||
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue