📄 hal_lut.c
字号:
/*
**===========================================================================
** HAL_LUT.C - This module contains the LUT routines for the 13505 HAL.
**---------------------------------------------------------------------------
** Copyright (c) 1997, 2001 Epson Research and Development, Inc.
** All Rights Reserved.
**===========================================================================
*/
#ifdef INTEL
#include <stdio.h>
#endif
#include "hal.h"
#include "assert.h"
#include "nonsefns.h"
/*-------------------------------------------------------------------------*/
static const char Revision[] = "HAL_LUT.C=$Revision: 2 $";
/*-------------------------------------------------------------------------*/
/*
** seSetLut()
**
** This function sets either all or a portion of the 256 color LUT.
**
*/
int seSetLut( int seReserved1, BYTE *pLUT, int count )
{
int idx, rgb;
ASSERT( 0 == seReserved1 );
ASSERT( count <= 256 );
/*
** Start at element 0 using auto-increment and set bank 0.
*/
WriteRegister( seReserved1, REG_LUT_ADDR, 0 );
for (idx = 0; idx < count; idx++)
{
for (rgb = 0; rgb < 3; rgb++)
WriteRegister( seReserved1, REG_LUT_DATA, *pLUT++ );
}
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seGetLut()
**
** This routine reads the entire LUT and puts the results in
** the array pointed to by pLut.
**
** One improvement would be to reduce the reads to only the number of
** elements required by the current colour depth.
**
** NOTES:
**
** - This routine fills only LUT bank 0. (i.e. the Look-Up Table Bank
** Select Register (register [16]) is set to 0 prior to loading the LUT.
** - pLUT MUST point to an array big enough to hold the entire 16 element
** look-up table regardless of colour depth.
*/
int seGetLut( int seReserved1, BYTE *pLUT, int count )
{
int idx, rgb;
ASSERT( 0 == seReserved1 );
ASSERT( count <= 256 );
WriteRegister( seReserved1, REG_LUT_ADDR, 0 );
for (idx = 0; idx < count; ++idx)
{
for (rgb = 0; rgb < 3; ++rgb)
*pLUT++ = ReadRegister( seReserved1, REG_LUT_DATA );
}
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seSetLutEntry()
**
** This function writes just one LUT entry.
**
** NOTE:
**
** - pLUT must point to a valid LUT data entry (BYTE lut[3])
**
*/
int seSetLutEntry( int seReserved1, int index, BYTE *pLUT )
{
ASSERT( 0 == seReserved1 );
ASSERT( index <= 256 );
/*
** Set the element index with auto-increment.
*/
WriteRegister( seReserved1, REG_LUT_ADDR, (BYTE) index );
WriteRegister( seReserved1, REG_LUT_DATA, *pLUT++ );
WriteRegister( seReserved1, REG_LUT_DATA, *pLUT++ );
WriteRegister( seReserved1, REG_LUT_DATA, *pLUT );
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seGetLutEntry()
**
** This function reads just one LUT entry.
**
** NOTE:
**
** - pLut must point to a valid LUT data entry (BYTE LUT[3])
*/
int seGetLutEntry( int seReserved1, int index, BYTE *pLut )
{
ASSERT( 0 == seReserved1 );
ASSERT( index <= 256);
WriteRegister( seReserved1, REG_LUT_ADDR, (BYTE) index );
*pLut++ = ReadRegister( seReserved1, REG_LUT_DATA );
*pLut++ = ReadRegister( seReserved1, REG_LUT_DATA );
*pLut = ReadRegister( seReserved1, REG_LUT_DATA );
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -