저레벨 프로그래밍에 대한 경험이 없으며 [StructLayout (LayoutKind.Explicit)]을 사용하지 않는 코드 조각이 필요합니다. 내 사이트는 공유 호스트와 중간 신뢰에서 실행됩니다. 이 코드가 있으면 실행되지 않습니다.[StructLayout]을 System.Runtime.InteropServices를 사용하지 않는 것으로 바꾸십시오?
업데이트 : Octree 내부에서이를 사용하여 png 파일을 퀀트 화합니다.
해결 방법이 있습니까? 여기 =>Is there any way to do Image Quantization safely and with no Marshalling?
/// <summary>
/// Struct that defines a 32 bpp colour
/// </summary>
/// <remarks>
/// This struct is used to read data from a 32 bits per pixel image
/// in memory, and is ordered in this manner as this is the way that
/// the data is layed out in memory
/// </remarks>
[StructLayout(LayoutKind.Explicit)]
public struct Color32
{
public Color32(IntPtr pSourcePixel)
{
this = (Color32)Marshal.PtrToStructure(pSourcePixel, typeof(Color32));
}
/// <summary>
/// Holds the blue component of the colour
/// </summary>
[FieldOffset(0)]
public byte Blue;
/// <summary>
/// Holds the green component of the colour
/// </summary>
[FieldOffset(1)]
public byte Green;
/// <summary>
/// Holds the red component of the colour
/// </summary>
[FieldOffset(2)]
public byte Red;
/// <summary>
/// Holds the alpha component of the colour
/// </summary>
[FieldOffset(3)]
public byte Alpha;
/// <summary>
/// Permits the color32 to be treated as an int32
/// </summary>
[FieldOffset(0)]
public int ARGB;
/// <summary>
/// Return the color for this Color32 object
/// </summary>
public Color Color
{
get { return Color.FromArgb(Alpha, Red, Green, Blue); }
}
}
무엇을 하시겠습니까? Bitmap 클래스를 사용할 수 없습니까? –
비 관리 코드를 사용하는 이유와 방법에 대해 약간의 배경 지식을 제공 할 수 있습니까? –
그가 다른 바이트 순서로 다른 소스의 데이터와 상호 작용하려고 시도하는 것처럼 보일 것입니다 – ShuggyCoUk