C # parse the SUM grating file image (RAS file)

Source: Internet
Author: User

Usage,

ImageRas _ Ras = new ImageRas (@ "D: empest. ras ");
PictureBox1.Image = _ Ras. Image;

_ Ras. SaveRas (@ "d: empOK. ras ");

I only implemented the 24-bit color and 8-bit color structure, which is too simple. Only the file header and data area are supported. The 8-bit color table has some special features.

First, the red table, the green table, and the blue table are usually RGB and RGB. In this case, the RRRR... GGG... B ....

I don't know what to think.

There is little time to do these things when there are too many projects. The next target is the IFF file.

All code
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 Raster image 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 private
/// <Summary>
/// File Header 956AA659
/// </Summary>
Private uint m_Mageic = 0x956AA659;

/// <Summary>
/// Width
/// </Summary>
Private uint m_Width = 0;

/// <Summary>
/// High
/// </Summary>
Private uint m_Height = 0;

/// <Summary>
/// Color depth
/// </Summary>
Private uint m_Depth = 0;

/// <Summary>
/// Data size in the graphic Area
/// </Summary>
Private uint m_Length = 0;

/// <Summary>
/// Data Type
/// </Summary>
Private uint m_Type = 0;

/// <Summary>
/// Color image type
/// </Summary>
Private uint m_MapType = 0;

/// <Summary>
/// Color Length
/// </Summary>
Private uint m_MapLength = 0;

/// <Summary>
/// Color table
/// </Summary>
Private Color [] m_ColorList = new Color [256];

/// <Summary>
/// Image
/// </Summary>
Private Bitmap m_Image;
# Endregion

/// <Summary>
/// Obtain the image
/// </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)
&

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.