使用方法、
ImageRas _Ras = new ImageRas(@"D: emp est.ras");
pictureBox1.Image = _Ras.Image;
_Ras.SaveRas(@"d: empOK.ras");
我只實現了24位色和8位色 這個結構也太簡單了。只有文件頭和數據區 。就是8位色的色彩表有些特殊
先是紅色表 綠色表 藍色表 平時都是 RGB、RGB 這樣放 這東西居然RRRR.....GGG......B....
不知道怎麼想的。
項目多了很少有時間做這些東西了。下個目標是IFF文件
全部代碼
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;
namespace Zgke.MyImage.ImageFile
{
/// <summary>
/// SUN光柵圖形 RAS
/// [email protected]
/// qq:116149
/// </summary>
public class ImageRas
{
public ImageRas(string p_ImageFile)
{
if (System.IO.File.Exists(p_ImageFile))
{
LoadImage(System.IO.File.ReadAllBytes(p_ImageFile));
}
}
public ImageRas()
{
}
#region 私有
/// <summary>
/// 文件頭 956AA659
/// </summary>
private uint m_Mageic = 0x956AA659;
/// <summary>
/// 寬
/// </summary>
private uint m_Width = 0;
/// <summary>
/// 高
/// </summary>
private uint m_Height = 0;
/// <summary>
/// 顏色深
/// </summary>
private uint m_Depth = 0;
/// <summary>
/// 圖形區域數據大小
/// </summary>
private uint m_Length = 0;
/// <summary>
/// 數據類型
/// </summary>
private uint m_Type = 0;
/// <summary>
/// 色彩圖形類型
/// </summary>
private uint m_MapType = 0;
/// <summary>
/// 色彩長度
/// </summary>
private uint m_MapLength = 0;
/// <summary>
/// 顏色表
/// </summary>
private Color[] m_ColorList = new Color[256];
/// <summary>
/// 圖形
/// </summary>
private Bitmap m_Image;
#endregion
/// <summary>
/// 獲取圖形
/// </summary>
public Bitmap Image
{
get
{
return m_Image;
}
set
{
if (value != null)
{
m_Image = value;
m_Width = (uint)value.Width;
m_Height = (uint)value.Height;
switch (value.PixelFormat)
&