Click here to Skip to main content
15,892,697 members
Articles / Desktop Programming / Win32

RGB to YUV conversion with different chroma sampling using C++,

Rate me:
Please Sign up or sign in to vote.
4.67/5 (15 votes)
10 Jul 2012CPOL4 min read 120.2K   8.7K   49  
RGB to YUV conversion with different chroma sampling using C++.
// BitmapClass.h: interface for the BitmapClass class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BITMAPCLASS_H__82B78722_38FB_4501_AEA0_8256E93FF534__INCLUDED_)
#define AFX_BITMAPCLASS_H__82B78722_38FB_4501_AEA0_8256E93FF534__INCLUDED_



#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef enum
{
    BMP_24,
    BMP_32,
    BMP_8
}IMAGE_TYPE;

class BitmapClass
{

public:

    BitmapClass();
    ~BitmapClass();
    bool Open( CString cFilePath_i );
    void Draw( HWND hwnd, int nXStart_i, int nYStart_i, int nWidth_i, int nHeight_i );
    void ResetDisplay( HWND hwnd, int nXStart_i, int nYStart_i, int nWidth_i, int nHeight_i );
    void CreateBitmap( const byte* ptr_i, int& nWidth_i, int& nHeight_i, IMAGE_TYPE eImageType_i );

    int  Width()
    {
        return m_BMPInfoHeader.biWidth;
    };
    int  Heigth()
    {
        return m_BMPInfoHeader.biHeight;
    };
    unsigned char*  Data()
    {
        return m_pbyPixelData;
    }

private:

    bool ReadBMPFileHeaderInformations( const void* ptr_i );
    bool ReadBMPInfoHeaderInformations( const void* ptr_i );
    void ReadPixelData( const void* ptr_i );
    void Create32BitData( );

    BITMAPFILEHEADER    m_BMPFileHeader;
    BITMAPINFOHEADER    m_BMPInfoHeader;
    byte*               m_pbyPixelData;
    byte*               m_pby32PixelData;
};

#endif // !defined(AFX_BITMAPCLASS_H__82B78722_38FB_4501_AEA0_8256E93FF534__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions