国产探花免费观看_亚洲丰满少妇自慰呻吟_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);
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 霍城县| 鞍山市| 桂东县| 信阳市| 台湾省| 寻乌县| 白玉县| 桃源县| 雷波县| 河北区| 临沭县| 阿拉善盟| 黄冈市| 类乌齐县| SHOW| 任丘市| 涿州市| 靖边县| 定结县| 甘孜县| 张北县| 西昌市| 塘沽区| 司法| 大同县| 鄂尔多斯市| 亳州市| 儋州市| 凌云县| 瑞丽市| 安国市| 论坛| 张家口市| 陆河县| 南和县| 平南县| 平山县| 承德县| 澳门| 锦屏县| 龙泉市|