using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
namespace Zgke.MyImage.ImageFile
{
/// <summary>
/// CUR文件操作类
/// zgke@sina.com
/// qq:116149
/// </summary>
public class ImageCur
{
private class CurHead
{
private byte[] m_Retain = new byte[2];
private byte[] m_Type = new byte[] { 0x02, 0x00 };
private byte[] m_ImageCount = new byte[2];
private byte m_ImageWidth;
private byte m_ImageHeight;
private byte m_ColorCount;
private byte[] m_NotUser = new byte[5];
private byte[] m_ImageLength = new byte[4];
private byte[] m_ImageRVA = new byte[4];
/// <summary>
/// 图形高
/// </summary>
public byte ImageHeight { get { return m_ImageHeight; } set { m_ImageHeight = value; } }
/// <summary>
/// 图象个数
/// </summary>
public ushort ImageCount { get { return BitConverter.ToUInt16(m_ImageCount, 0); } set { m_ImageCount = BitConverter.GetBytes(value); } }
/// <summary>
/// 图形宽
/// </summary>
public byte ImageWidth { get { return m_ImageWidth; } set { m_ImageWidth = value; } }
/// <summary>
/// 色彩数 (256以下色用)
/// </summary>
public byte ColorCount { get { return m_ColorCount; } set { m_ColorCount = value; } }
/// <summary>
/// 图象数据块的长度
/// </summary>
public uint ImageLength { get { return BitConverter.ToUInt32(m_ImageLength, 0); } set { m_ImageLength = BitConverter.GetBytes(value); } }
/// <summary>
/// 图象数据块相对于文件头部的偏移量
/// </summary>
public uint ImageRVA { get { return BitConverter.ToUInt32(m_ImageRVA, 0); } set { m_ImageRVA = BitConverter.GetBytes(value); } }
public CurHead()
{
}
public CurHead(byte[] p_Data)
{
ImageCount = BitConverter.ToUInt16(p_Data, 4);
ImageHeight = p_Data[7];
ImageWidth = p_Data[6];
ColorCount = p_Data[8];
ImageLength = BitConverter.ToUInt32(p_Data, 14);
ImageRVA = BitConverter.ToUInt32(p_Data, 18);
}
public byte[] GetByte()
{
byte[] _ReturnBytes = new byte[22];
_ReturnBytes[0] = m_Retain[0];
_ReturnBytes[1] = m_Retain[1];
_ReturnBytes[2] = m_Retain[0];
_ReturnBytes[3] = m_Retain[1];
_ReturnBytes[4] = m_ImageCount[0];
_ReturnBytes[5] = m_ImageCount[1];
_ReturnBytes[6] = m_ImageWidth;
_ReturnBytes[7] = m_ImageHeight;
_ReturnBytes[8] = m_ColorCount;
_ReturnBytes[14] = m_ImageLength[0];
_ReturnBytes[15] = m_ImageLength[1];
_ReturnBytes[16] = m_ImageLength[2];
_ReturnBytes[17] = m_ImageLength[3];
_ReturnBytes[18] = m_ImageRVA[0];
_ReturnBytes[19] = m_ImageRVA[1];
_ReturnBytes[20] = m_ImageRVA[2];
_ReturnBytes[21] = m_ImageRVA[3];
return _ReturnBytes;








