pixel.cpp

来自「Vc.Net入门与提高源码」· C++ 代码 · 共 67 行

CPP
67
字号
// Pixel.cpp : Implementation of CPixel
#include "stdafx.h"
#include "Picture.h"
#include "Pixel.h"

/////////////////////////////////////////////////////////////////////////////
// CPixel


STDMETHODIMP CPixel::get_Color(baseColors *pVal)
{
    *pVal = m_color;
	return S_OK;
}

STDMETHODIMP CPixel::put_Color(baseColors newVal)
{
    HRESULT hr = S_OK;

    // Test if the new color is valid or not
    if (newVal < 0 || newVal > 15)
        return AtlReportError(CLSID_Pixel, IDS_BAD_COLOR, 
                    IID_IPixel, 0, _Module.GetModuleInstance());

    if (SUCCEEDED(hr = IsReadOnly()))
        m_color = newVal;
	return hr;
}

STDMETHODIMP CPixel::get_Row(long *pVal)
{
	*pVal = m_row;
	return S_OK;
}

STDMETHODIMP CPixel::put_Row(long newVal)
{
    HRESULT hr = S_OK;
    if (SUCCEEDED(hr = IsReadOnly()))
    	m_row = newVal;
	return hr;
}

STDMETHODIMP CPixel::get_Column(long *pVal)
{
    *pVal = m_col;
	return S_OK;
}

STDMETHODIMP CPixel::put_Column(long newVal)
{
    HRESULT hr = S_OK;
    if (SUCCEEDED(hr = IsReadOnly()))
    	m_col = newVal;
	return hr;
}

HRESULT CPixel::IsReadOnly()
{
    // Test if this pixel is in readonly mode
    if (m_bReadOnly)
        return AtlReportError(CLSID_Pixel, IDS_READONLY_PIXEL,
            IID_IPixel, 0, _Module.GetModuleInstance());
    else 
        return S_OK;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?