国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C# 解析 RAS文件 SUM 光柵文件圖象的代碼

2024-09-07 17:05:26
字體:
來源:轉載
供稿:網友
使用方法:
代碼如下:
ImageRas _Ras = new ImageRas(@"D:/temp/test.ras");
pictureBox1.Image = _Ras.Image;
_Ras.SaveRas(@"d:/temp/OK.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
/// zgke@sina.com
/// 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)
{
case PixelFormat.Format8bppIndexed:
break;
case PixelFormat.Format32bppArgb:
break;
default:
m_Depth = 24;
break;
}
}
}
}
/// <summary>
/// 獲取數據
/// </summary>
/// <param name="p_ImageBytes"></param>
private void LoadImage(byte[] p_ImageBytes)
{
if (BitConverter.ToUInt32(p_ImageBytes, 0) != m_Mageic) throw new Exception("文件頭不正確!");
m_Width = BytesToUint(p_ImageBytes, 4);
m_Height = BytesToUint(p_ImageBytes, 8);
m_Depth = BytesToUint(p_ImageBytes, 12);
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 象州县| 泾川县| 富锦市| 文化| 城口县| 东宁县| 台北县| 鹤峰县| 珲春市| 七台河市| 定西市| 青田县| 海原县| 福建省| 新民市| 平山县| 镇沅| 东兰县| 溆浦县| 上饶市| 隆化县| 南部县| 沙河市| 筠连县| 德阳市| 洪洞县| 南城县| 周口市| 宣恩县| 寿光市| 宿州市| 桑植县| 桑日县| 文安县| 天全县| 维西| 通州市| 固原市| 高邑县| 通州区| 长丰县|