JPEG color conversion implementation file

zhaozj2021-02-08  224

YUVTORGB.CPP - ISEE Image Browser JPEG Color Conversion Implementation File

Copyright (c) Vchelp-Copathway-Isee Workgroup 2000 All Member's

This procedure is free software, you can follow the GNU universal public publication published in the Free Software Foundation

Creation Terms to modify and re-release this procedure. Or use the second edition of the license, or (root

According to your choice) use any updated version.

The purpose of publishing this program is to hope it is useful, but there is no guarantee. Even not suitable for specific

Focus on hidden guarantees. For more detailed information, please refer to the GNU universal public license.

You should have received a copy of a GNU universal public license with a program. If not yet,

Write to:

The Free Software Foundation, Inc., 675 Mass Ave, Cambridge,

MA02139, USA

If you have any questions or suggestions when using this software, you can get together with us with us with the following address.

system:

Http://isee.126.com

http://www.vchelp.net

or:

Yzfree@sina.com

Author: analyst

file version:

Build 00523

Date 2000-5-23

*********************************************************** ****************** /

Static Int CR1_402 [256], CB0_34414 [256], CR0_71414 [256], CB1_772 [256]

init ()

{

/// ..........

For (i = 0; i <256; i )

{

CR1_402 [I] = (int) (1.402 * (SIGNED Char) i 1);

CB0_34414 [I] = (int) (- 0.34414 * (Signed Char) i 1);

CR0_71414 [I] = (int) (- 0.71414 * (Signed char) i 1);

CB1_772 [I] = (int) (1.772 * (signed char) i 1);

}

/// ..........

}

DWORD YUV_RGB32 (Int Y, Int R, Int G, INT B)

{

Y = 128; R = Y;

B = Y; g = y;

IF (r <0) r = 0; if (g <0) g = 0; IF (b <0) b = 0;

IF (r> 255) r = 255; if (g> 255) g = 255; if (b> 255) b = 255;

Return R << 16 & Brvbarg << 8 & Brvbarb;

}

Void YcBCR411_RGB32 (DWORD * BMPPIXEL, INT PITCH)

{

INT I, J, CB, CR, M;

INT R, G, B;

Signed char * crbuf = (signed char *) JPEG_CRBUF;

Signed char * CBBUF = (SIGNED Char *) JPEG_CBBBUF;

Signed char * YBUF = (SIGNED Char *) JPEG_YBUF;

For (m = 0; M <4; M , bMppixel - = (m & 1) * pitch * 2-8 16 * (m == 2))

For (i = 0; i <8; i = 2) {

For (j = 0; j <8; j = 2) {

CB = CBBUF [(I / 2 4 * (m / 2)) * 8 J / 2 4 * (M & 1)]; Cr = CRBUF [(I / 2 4 * (m / 2)) * 8 J / 2 4 * (M & 1)];

R = CR1_402 [(Byte) Cr];

G = CB0_34414 [(Byte) CB] CR0_71414W [(Byte) Cr];

B = CB1_772 [(Byte) CB];

* BMPPIXEL = YUV_RGB32 (YBUF [i * 8 J 128 * M], R, G, B), BMPPixel

* bmpixel = yuv_rgb32 (YBUF [i * 8 J 1 128 * m], r, g, b), bMPPixel

* (BMPPIXEL PITCH / 4-2) = yuv_rgb32 (YBUF [i * 8 J 8 128 * M], R, G, B);

* (BMPPIXEL PITCH / 4-1) = yuv_rgb32 (YBUF [i * 8 J 9 128 * M], R, G, B);

}

BMPPixel = (DWORD *) ((unsigned) BMPPixel Pitch * 2-32);

}

}

Void Ycbcr111_RGB32 (DWORD * BMPPIXEL, INT PITCH)

{

INT I, J, CB, CR;

INT R, G, B;

Signed char * crbuf = (signed char *) JPEG_CRBUF;

Signed char * CBBUF = (SIGNED Char *) JPEG_CBBBUF;

Signed char * YBUF = (SIGNED Char *) JPEG_YBUF;

For (i = 0; i <8; i ) {

For (j = 0; j <8; j ) {

CB = CBBUF [i * 8 j];

Cr = CRBUF [i * 8 j];

R = CR1_402 [(Byte) Cr];

G = CB0_34414 [(Byte) CB] CR0_71414W [(Byte) Cr];

B = CB1_772 [(Byte) CB];

* BMPPIXEL = YUV_RGB32 (YBUF [i * 8 J], R, G, B), BMPPixel

}

BMPPIXEL = (DWORD *) ((unsigned) BMPPixel PITCH-32);

}

}

/ * Gray mode * /

Void YYY_RGB32 (DWORD * BMPPIXEL, INT PITCH)

{

INT I, J;

Int Y;

Signed char * YBUF = (SIGNED Char *) JPEG_YBUF;

For (i = 0; i <8; i ) {

For (j = 0; j <8; j ) {

Y = YBUF [i * 8 j] 128;

* BMPPIXEL = Y << 16 & brvbary << 8 & brvbary;

bmpixel;

}

BMPPIXEL = (DWORD *) ((unsigned) BMPPixel PITCH-32);

}

}

转载请注明原文地址:https://www.9cbs.com/read-2519.html

New Post(0)