the Internet Windows Android

What is the image in the RGB format. Color model RGB.

I recently wrote the code to make exactly this, based on the universal color format converter SCUMMVM.

The answer to another question here is on Stackoverflow, and although the question is, in my opinion, is not a duplicate, I think the answer is, so I'll just contact him:

Remember, I definitely do not know how the multiplier for each factor works in 5-6-5 format. Is the 6-bit component just more accurate? In this case automatic system Transformation will perform this work.

In any case, with the above code, this example must best satisfy your needs. Here it is used to convert user format 5-5-5-1 RGBA:

// BYTS 84 21 \u003d\u003d\u003e 0x8421 (BE) \u003d\u003d bin \u003d\u003d\u003e 1000 0100 0010 0001 \u003d\u003d Split \u003d\u003d\u003e 10000 10000 10000 1 \u003d\u003d DEC \u003d\u003d\u003e 16 16 16 1 (RGBA) \u003d\u003d adjust \u003d\u003d \u003e 128 128 128 255 // Values \u200b\u200bin Constructor Are: Bytes Per Pixel, Amount of Bits and Amount to SHIFT for Getting R, G, B and a Components, and Data Endianness. Private Static PixelFormatter SixteenBppFormatter \u003d New PixelFormatter (2, 5, 11, 5, 6, 5, 1, 1, 0, FALSE); Protected Static Byte Convert16BTO32B (Byte Imagedata, int32 startoffset, int32 width, int32 height, ref int32 stride) (int32 newimagestride \u003d width * 4 ;; byte newimagedata \u003d new byte; for (int32 y \u003d 0; y< height; y++) { for (Int32 x = 0; x < width; x++) { Int32 sourceOffset = y * stride + x * 2; Int32 targetOffset = y * newImageStride + x * 4; Color c = SixteenBppFormatter.GetColor(imageData, startOffset + sourceOffset); PixelFormatter.Format32BitArgb.WriteColor(newImageData, targetOffset, c); } } stride = newImageStride; return newImageData; }

All you need to do is define your own Pixelformatter with the correct distribution of bits for format 5-6-5.

You really need to look into bitmap.lockbits () to get source 16-bit data from the image and write this data to a new 32-bit image ARGB. My Buildimage feature mentioned in this response should show how to process record. The reading method is actually much easier:

///

/// Gets the Raw Bytes from An Image. /// /// The Image to Get The Bytes From. /// Stride of the Retrieved Image Data. /// The Raw Bytes of the Image public static Byte GetImageData (Bitmap sourceImage, out Int32 stride) (BitmapData sourceData \u003d sourceImage.LockBits (new Rectangle (0, 0, sourceImage.Width, sourceImage.Height), ImageLockMode.ReadOnly, sourceImage.PixelFormat); stride \u003d sourceData.Stride ; Byte Data \u003d New Byte; Marshal.copy (sourcedata.scan0, data, 0, data.length); sourceimage.unlockbits (sourcedata); Return Data;)

Please note that in all situations when you edit bytes of untreated images, the difference between the "steps" and "width". In many formats, one pixel line in the image is complemented by the next fold of the four bytes, so you cannot simply read and process it as an array, which assumes all image data; These capital bytes will be very fast. As shown in my example code to convert my 16BPP format in ArgB, you really need to do this in turn, and in each line, make sure that you only use the data that are still in the range (width * bytes per pixel).

I noticed that for all functions that can change step, it is recommended to specify it as Ref.

The most convenient, common, universal way to specify color - RGB. RGB is an abbreviation (Red Green Blue), which means: red, green, blue - basic colors, by combining which all other colors are obtained.

Color with RGB can be installed in several ways, then in detail about each.

Functional color recording format in CSS

The general view of the functional format: RGB (color), where "color" is a combination of three integers (from 0 to 255) or three percentage values \u200b\u200b(from 0% to 100%) listed through a comma. Next, a few examples.

RGB (255, 255, 255) / * White Color * /
rGB (0, 0, 0) / * black color * /
rGB (255, 0, 0) / * red color * /

RGB (100%, 100%, 100%) / * White Color * /
rGB (0%, 0%, 0%) / * black color * /
rGB (100%, 0%, 0%) / * Red color * /

After RGB and before (there is no space!

Now let's make the text of the header text with some randomic color, for example, RGB (222, 14, 100), is some kind of pink or purple color. Further an example of application.

H1 (
Color: RGB (222, 14, 100);
}

And now with the help of interest values \u200b\u200band RGB, create a couple of shades of green. This is an example 4.

Example 4, CSS Code

P.One (Color: RGB (0%, 20%, 0%);)
p.TWO (Color: RGB (0%, 40%, 0%);)
p.Three (Color: RGB (0%, 60%, 0%);)
p.FOUR (Color: RGB (0%, 80%, 0%);)
p.five (Color: RGB (0%, 100%, 0%);)

Example 4, HTML Code

Green


Green


Green


Green


Green

By the way, the percentages can be written fractional, for example, RGB (40.2%, 22.34%, 12%), so the color will be more accurate.

And what happens if we go beyond the range of values? There will be nothing special, just values \u200b\u200bwill be interpreted to the nearest boundaries (0% or 100%, 0 or 255). Then an example is the fifth.

RGB (200%, 3100%, 101%) / * will be RGB (100%, 100%, 100%) * /
rGB (-200%, 0%, 12%) / * will be RGB (0%, 0%, 12%) * /
rGB (257, -130, 212) / * will be RGB (255, 0, 212) * /

Suppose we have the following CSS code: RGB (12%, 96%, 43%) and we need to translate interest values \u200b\u200binto integers. This is done very simply, you need to multiply each level by 255, and then divided by 100, as a result we obtain RGB (30.6, 244.8, 109.65), after we are rounded according to the rules of mathematics and get the desired: RGB (31, 245, 110).

Sandent color recording format in CSS

I most often use precisely hexadecimal format, it's just shorter. Further example.

P (Color: #FFFFFF;) / * White text color * /
p (Color: # 000000;) / * Black text color * /
p (Color: # FF0000;) / * Red text * /

There are almost no differences from RGB. The three colors of RRGGBB are specified in the range from 00 to FF (FF is 255 in the decimal system). As you can see, between numbers and letters there are no spaces and other signs (the second reason why I like this format more), and hexadecimal code begins with the grille (#). By the way, hexadecimal format is called HEX format. Further, an example of three identical colors that are written in three ways.

Do you have a problem with opening.RGB files? We collect information about file formats and can tell for which the RGB files are needed. Additionally, we recommend programs that are most suitable for opening or converting such files.

Why do you need file format.RGB?

Derived from standard designation additive color model RGB (red, green, blue), extension .rgb. Related to the file type "Color raster image RGB SGI" - part of a wider SGI image file format (SGI Image File Format). Now stopped its activities, SGI (Original Silicon Graphics) was a pioneer in the field of high-performance graphics stations based on UNIX and developed its own common raster format. A full SGI raster format specification was published.

File .rgb. It is a color raster image RGB (24-bit color) in SGI format. In addition to the uncompressed mode, SGI format also provides for RLE-compression (RUN LENGTH Encoding - group coding). In one file .rgb. There may be one raster image.



SGI RGB files are recognized and supported by most basic graphic editors and programs for viewing in most of the custom environments. In addition to .rgb. SGI raster images can have other extensions, namely .rgb.a (32-bit RGBA images) and .sgi (overall expansion).

In similar quality expansion .rgb. may sometimes meet with applied to rare typical format of color raster images Q0 (RGB, 24-bit color). This format is also recognized and supported by most basic graphic viewers / editors.

Programs for opening or converting RGB files

You can open RGB files using the following programs: 

RGB model describes emitted colors. It is based on three main (basic) colors: red (Red), green (Green) and blue (Blue). The RGB model can be called "native" for the display. The remaining colors are obtained by a combination of basic. The colors of this type are called additive.

It can be seen from the drawing that the combination of green and red give yellow color, a combination of green and blue - blue, and a combination of all three colors is white. From this it can be concluded that colors in RGB are subtractive.

The main colors are taken from human biology. That is, these colors are based on the physiological response of the human eye to the light. The human eye has a photoreceptor cells that react to the most green (M), yellow-green (L) and blue-violet (S) light ( maximum length Waves from 534 nm, 564 nm and 420 nm, respectively). The human brain can easily distinguish a wide range of different colors based on differences in signals obtained from three waves.

The most wide RGB color model is used in LCD or plasma displays, such as a TV or computer monitor. Each pixel on the display can be presented in the hardware interface (for example, graphic maps) as values \u200b\u200bof red, green and blue. RGB values \u200b\u200bare changed in the intensity, which are used for clarity. Cameras and scanners also work in the same order, they capture color with sensors that register various RGB intensity for each pixel.

In 16 bits mode, the pixel, also known as HighColor, has either 5 bits on color (often referred to as 555 mode) or with an additional bit for green (known as 565 mode). The green color is supplemented due to the fact that the human eye has the ability to identify more shades of green than any other color.

RGB values \u200b\u200bpresented in 24 bits mode on pixel (BPP), also known as TrueColor, is usually distinguished by three integers between 0 and 255. Each of these three numbers is the intensity of red, green and blue, respectively.

In RGB - three channels: red, blue and green, i.e. RGB - Three-channel color model. Each channel can take values \u200b\u200bfrom 0 to 255 in decimal or, closer to reality, from 0 to FF in hexadecimal number systems. This is explained by the fact that the byte, which is encoded by the channel, and indeed any byte consists of eight bits, and the bit can take 2 values \u200b\u200b0 or 1, and tight 28 \u003d 256. In RGB, for example, a red color can take 256 gradations: from purely red (FF) to black (00). Thus, it is easy to calculate that the RGB model contains only 2563 or 16777216 colors.

In RGB, three channels, and each is encoded by 8 bits. Maximum, FF (or 255) The value gives pure color. White color is obtained by combining all colors, more precisely, their limit gradations. White Code \u003d FF (Red) + FF (Green) + FF (Blue). Accordingly, the code is black \u003d 000000. The code is yellow \u003d FFFF00, purple \u003d FF00FF, blue \u003d 00FFFF.

There are also 32 and 48 bit colors display modes.

RGB is not used for printing on paper, instead there is a CMYK-color space.

CMYK is the color model used in color printing. Color model It is a mathematical model for describing colors with integers. CMYK model is built on blue, purple, yellow and black colors.