daily update on 20241002 by nitload youmu, intrinsic function rebuild, syntax style arrange
This commit is contained in:
@@ -36,6 +36,8 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public interface IImageProvider
|
||||
{
|
||||
|
||||
Image ProvideImage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,23 +30,35 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public static class ImageHelper
|
||||
{
|
||||
public static void Resize(Image i, int width, int height, ImageMovement move)
|
||||
|
||||
public static void Resize(
|
||||
Image i,
|
||||
int width,
|
||||
int height,
|
||||
ImageMovement move )
|
||||
{
|
||||
if (i == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(i));
|
||||
if( i == null ) {
|
||||
throw new ArgumentNullException( nameof( i ) );
|
||||
}
|
||||
Array.Resize(ref i.Data, width * height * i.PixelSize);
|
||||
if( i.Size == (width, height) ) {
|
||||
return;
|
||||
}
|
||||
if( !Enum.IsDefined( typeof( ImageMovement ), move ) ) {
|
||||
throw new InvalidEnumArgumentException( nameof( move ) );
|
||||
}
|
||||
byte[] oldData = i.Data;
|
||||
i.Data = new byte[width * height * i.PixelSize];
|
||||
i.Height = height;
|
||||
i.Width = width;
|
||||
switch (move)
|
||||
{
|
||||
i.PixelUpdateCount++;
|
||||
switch( move ) {
|
||||
case ImageMovement.Discard:
|
||||
break;
|
||||
case ImageMovement.Top:
|
||||
@@ -54,8 +66,8 @@ namespace StgSharp.Graphics
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
i.PixelUpdateCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Flags]
|
||||
@@ -63,7 +75,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
#pragma warning disable CA1008
|
||||
Discard = 0,
|
||||
#pragma warning restore CA1008
|
||||
#pragma warning restore CA1008
|
||||
Top = 1,
|
||||
Bottom = 2,
|
||||
Left = 4,
|
||||
@@ -72,5 +84,6 @@ namespace StgSharp.Graphics
|
||||
BottomLeft = Bottom | Left,
|
||||
TopRight = Top | Right,
|
||||
BottomRight = Bottom | Right,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user