📄 haljpeg.c
字号:
{
//fill the whole screen to prevent the black region
//_wJPEGHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealWidth / (DWORD)__wHeight) / _fZoomRate);
_wJPEGHeight = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealWidth*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
__wDisplayHeight = __wHALJPEGDisplayBufWidth;
}
else
//__wDisplayHeight = (WORD)((float)((DWORD)__wHeight * (DWORD)_wJPEGRealHeight / (DWORD)_wJPEGRealWidth)*_fZoomRate);
__wDisplayHeight = (WORD)((DWORD)__wHeight*(DWORD)_wJPEGRealHeight/(DWORD)_wJPEGRealWidth*(DWORD)_bZoomRate/100L);
//_wJPEGWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)_wJPEGRealWidth / (DWORD)__wHeight) / _fZoomRate);
_wJPEGWidth = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealWidth*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
}
}
else
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
//_wJPEGWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth * (DWORD)_wJPEGRealWidth / (DWORD)__wWidth) /_fZoomRate);
_wJPEGWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealWidth*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
//if (((DWORD)(((float)((DWORD)__wWidth*(DWORD)_wJPEGRealHeight)*_fZoomRate)) / (DWORD)_wJPEGRealWidth) > __wHALJPEGDisplayBufHeight)
if (((DWORD)__wWidth*(DWORD)_wJPEGRealHeight*(DWORD)_bZoomRate/100L/(DWORD)_wJPEGRealWidth) > (DWORD)__wHALJPEGDisplayBufHeight)
{
//fill the whole screen to prevent the black region
//_wJPEGHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealWidth / (DWORD)__wWidth) / _fZoomRate);
_wJPEGHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealWidth*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
__wDisplayHeight = __wHALJPEGDisplayBufHeight;
}
else
//__wDisplayHeight = (WORD)((float)((DWORD)__wWidth * (DWORD)_wJPEGRealHeight / (DWORD)_wJPEGRealWidth)*_fZoomRate);
__wDisplayHeight = (WORD)((DWORD)__wWidth*(DWORD)_wJPEGRealHeight/(DWORD)_wJPEGRealWidth*(DWORD)_bZoomRate/100L);
}
else //fit height
{
//if (((DWORD)(((float)((DWORD)__wHeight*(DWORD)_wJPEGRealWidth)*_fZoomRate)) / (DWORD)_wJPEGRealHeight) > __wHALJPEGDisplayBufWidth)
if (((DWORD)__wHeight*(DWORD)_wJPEGRealWidth*(DWORD)_bZoomRate/100L/(DWORD)_wJPEGRealHeight) > (DWORD)__wHALJPEGDisplayBufWidth)
{
//fill the whole screen to prevent the black region
//_wJPEGWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealHeight / (DWORD)__wHeight) / _fZoomRate);
_wJPEGWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealHeight*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
__wDisplayWidth = __wHALJPEGDisplayBufWidth;
}
else
//__wDisplayWidth = (WORD)((float)((DWORD)__wHeight * (DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight)*_fZoomRate);
__wDisplayWidth = (WORD)((DWORD)__wHeight*(DWORD)_wJPEGRealWidth/(DWORD)_wJPEGRealHeight*(DWORD)_bZoomRate/100L);
//_wJPEGHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)_wJPEGRealHeight / (DWORD)__wHeight) / _fZoomRate);
_wJPEGHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealHeight*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
}
}
_ForceTo8Multiple(&_wJPEGWidth);
_ForceTo8Multiple(&_wJPEGHeight);
_ForceTo8Multiple(&__wDisplayWidth);
_ForceTo8Multiple(&__wDisplayHeight);
//Set the starting position to extract the image from FOrg.
__wHExtractStart = (_wJPEGRealWidth - _wJPEGWidth) >> 1;
__wVExtractStart = (_wJPEGRealHeight - _wJPEGHeight) >> 1;
_ForceTo8Multiple(&__wHExtractStart);
_ForceTo8Multiple(&__wVExtractStart);
}
}
}
W99AV_WriteDRAMData(W99AV_DRAM_JPEG_HCS, (((DWORD)__wHClipStart) << 16));
W99AV_WriteDRAMData(W99AV_DRAM_JPEG_VCS, (((DWORD)__wVClipStart) << 16));
W99AV_WriteDRAMData(W99AV_DRAM_JPEG_HCW, (((DWORD)__wHClipWidth) << 16));
W99AV_WriteDRAMData(W99AV_DRAM_JPEG_VCW, (((DWORD)__wVClipHeight) << 16));
#endif
return _bHALJPEGTemp2;
}
//***************************************************************************
// Function : _GetJPEGRotateStatus
// Abstract : Get the rotating status of JPEG.
// Arguments : none.
// Return : TRUE ==> The image is rotated 90 degree. (Rc or Rcc)
// : FALSE ==> The image is not rotated 90 degree.
// Side Effect : none.
// Notes : none.
//***************************************************************************
BYTE _GetJPEGRotateStatus(void)
{
#ifndef NO_PICTURECD
switch (__bJPEGOperation)
{
case HAL_JPEG_OPERATION_RC:
case HAL_JPEG_OPERATION_RCC:
case HAL_JPEG_OPERATION_RCFH:
case HAL_JPEG_OPERATION_RCFV:
return TRUE;
default:
break;
}
#endif
return FALSE;
}
//***************************************************************************
// Function : _ForceTo8Multiple
// Abstract : Transfer the value to 8's multiple.
// Arguments : wValue: The value you want to transfer to.
// Return : none.
// Side Effect : none.
// Notes : none.
//***************************************************************************
void _ForceTo8Multiple(WORD *wValue)
{
#ifndef NO_PICTURECD
#ifndef SUPPORT_JPEG_LARGE_BUFFER
*wValue = *wValue >> 3;
*wValue <<= 3;
#else
*wValue = (*wValue + 7) >> 3;
*wValue <<= 3;
#endif
#endif
}
//***************************************************************************
// Function : _JPEGDecodeCmd
// Abstract : Call "JPEG decode" macro command.
// Arguments : bMode : HAL_JPEG_DECODE==>Decode the JPEG
// : HAL_JPEG_NODECODE==>Don't decode the JPEG. For zoom&rotate&flip.
// Return : none.
// Side Effect : none.
// Notes : __wHStart, __wVStart ==>Strating position of the Displaying rectangle.
//***************************************************************************
void _JPEGDecodeCmd(BYTE bMode, BYTE bZoomFactor)
{
#ifndef NO_PICTURECD
__dwW99AVCmdArg[0] = 8;
__dwW99AVCmdArg[1] = CMDARG_JPEG_DECODE;
if (bMode == HAL_JPEG_DECODE)
{
__dwW99AVCmdArg[2] = (DWORD)1L << 24; //decode normal JPEG, CoCo2.81, Decode: [31:24]
}
else if (bMode == HAL_JPEG_NODECODE)
{
__dwW99AVCmdArg[2] = 0; //Don't decode; post-op
}
if (__SetupInfo.bProgressiveScan == SETUP_PROGRESSIVE_SCAN_OFF)
{
#ifdef _DEBUG_INFO
__dwW99AVCmdArg[2] |= (DWORD)__bJPEGFilter << 28;
#else
__dwW99AVCmdArg[2] |= (DWORD)JPEG_DEFAULT_BLUR << 28; //Tell RISC to do "filter" after decoding.
#endif
}
//CoCo2.81, Frame_buffer: [23:16]
__dwW99AVCmdArg[2] |= (DWORD)__btActiveFrame << 16; //decode the JPEG to the frame buffer.
//Operation: [15:0]
__dwW99AVCmdArg[2] |= __bJPEGOperation; //The operation for slide show.
if (__bThumbnailMode)
{
__dwW99AVCmdArg[3] = THUMBNAIL_BACKGROUND_COLOR; //thumbnail's background color
}
else
{
__dwW99AVCmdArg[3] = HAL_JPEG_SLIDESHOW_BACKGROUND_COLOR; //Slide show's background color
}
if (bZoomFactor > VIEW_ZOOM100)
{
__dwW99AVCmdArg[4] = MAKELONG(0, 0); //Strating position of the Displaying rectangle
__dwW99AVCmdArg[5] = MAKELONG(__wHALJPEGDisplayBufHeight, __wHALJPEGDisplayBufWidth); //The width and height of the displaying rectangle
}
else
{
__dwW99AVCmdArg[4] = MAKELONG(__wVStart, __wHStart); //Strating position of the Displaying rectangle
__dwW99AVCmdArg[5] = MAKELONG(__wHeight, __wWidth); //The width and height of the displaying rectangle
}
__dwW99AVCmdArg[6] = MAKELONG(__wVExtractStart, __wHExtractStart); //The starting horizontal position to extract picture from FOrg.
__dwW99AVCmdArg[7] = MAKELONG(_wJPEGHeight, _wJPEGWidth); //The width and height of the picture we want to extract from the FOrg.
__dwW99AVCmdArg[8] = MAKELONG(__wDisplayHeight, __wDisplayWidth); //The scaling width and height
W99AV_CommandN(COMMAND_JPEG);
#endif
}
//***************************************************************************
// Function : HAL_JPEGTransformOperation
// Abstract : Call this function to transform the result of "rotate" and "flip" to __bJPEGOperation.
// Arguments : bPreviousResult: HAL_JPEG_OPERATION_I,
// : HAL_JPEG_OPERATION_FH,
// : HAL_JPEG_OPERATION_FV,
// : HAL_JPEG_OPERATION_FHFV,
// : HAL_JPEG_OPERATION_RC,
// : HAL_JPEG_OPERATION_RCC,
// : HAL_JPEG_OPERATION_RCFH,
// : HAL_JPEG_OPERATION_RCFV
// : bCurrentOperation: HAL_JPEG_OPERATION_FH,
// : HAL_JPEG_OPERATION_FV,
// : HAL_JPEG_OPERATION_RC,
// : HAL_JPEG_OPERATION_RCC
// Return : none. The transformed result will be saved in __bJPEGOperation.
// Side Effect : none.
// Notes : Call this function to update __bJPEGOperation before calling HAL_ZOOM or HAL_JPEGDecode.
//***************************************************************************
void HAL_JPEGTransformOperation(BYTE bPreviousResult, BYTE bCurrentOperation)
{
#ifndef NO_PICTURECD
switch (bPreviousResult)
{
case HAL_JPEG_OPERATION_I:
__bJPEGOperation = bCurrentOperation;
break;
case HAL_JPEG_OPERATION_RC:
{
switch (bCurrentOperation)
{
case HAL_JPEG_OPERATION_RC:
__bJPEGOperation = HAL_JPEG_OPERATION_FHFV;
break;
case HAL_JPEG_OPERATION_RCC:
__bJPEGOperation = HAL_JPEG_OPERATION_I;
break;
case HAL_JPEG_OPERATION_FH:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFH;
break;
case HAL_JPEG_OPERATION_FV:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFV;
break;
default:
break; //__bJPEGOperation is the same as the previous.
}
}
break;
case HAL_JPEG_OPERATION_RCC:
{
switch (bCurrentOperation)
{
case HAL_JPEG_OPERATION_RC:
__bJPEGOperation = HAL_JPEG_OPERATION_I;
break;
case HAL_JPEG_OPERATION_RCC:
__bJPEGOperation = HAL_JPEG_OPERATION_FHFV;
break;
case HAL_JPEG_OPERATION_FH:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFV;
break;
case HAL_JPEG_OPERATION_FV:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFH;
break;
default:
break; //__bJPEGOperation is the same as the previous.
}
}
break;
case HAL_JPEG_OPERATION_FH:
{
switch (bCurrentOperation)
{
case HAL_JPEG_OPERATION_RC:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFV;
break;
case HAL_JPEG_OPERATION_RCC:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFH;
break;
case HAL_JPEG_OPERATION_FH:
__bJPEGOperation = HAL_JPEG_OPERATION_I;
break;
case HAL_JPEG_OPERATION_FV:
__bJPEGOperation = HAL_JPEG_OPERATION_FHFV;
break;
default:
break; //__bJPEGOperation is the same as the previous.
}
}
break;
case HAL_JPEG_OPERATION_FV:
{
switch (bCurrentOperation)
{
case HAL_JPEG_OPERATION_RC:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFH;
break;
case HAL_JPEG_OPERATION_RCC:
__bJPEGOperation = HAL_JPEG_OPERATION_RCFV;
break;
case HAL_JPEG_OPERATION_FH:
__bJPEGOperation = HAL_JPEG_OPERATION_FHFV;
break;
case HAL_JPEG_OPERATION_FV:
__bJPEGOperation = HAL_JPEG_OPERATION_I;
break;
default:
break; //__bJPEGOperation is the same as the previous.
}
}
break;
case HAL_JPEG_OPERATION_FHFV:
{
switch (bCurrentOperation)
{
case HAL_JPEG_OPERATION_RC:
__bJPEGOperation = HAL_JPEG_OPERATION_RCC;
break;
case HAL_JPEG_OPERATION_RCC:
__bJPEGOperation = HAL_JPEG_OPERATION_RC;
break;
case HAL_JPEG_OPERATION_FH:
__bJPEGOperation = HAL_JPEG_OPERATION_FV;
break;
case HAL_JPEG_OPERATION_FV:
__bJPEGOperation = HAL_JPEG_OPERATION_FH;
break;
default:
break; //__bJPEGOperation is the same as the previous.
}
}
break;
case HAL_JPEG_OPERATION_RCFH:
{
switch (bCurrentOperation)
{
case HAL_JPEG_OPERATION_RC:
__bJPEGOperation = HAL_JPEG_OPERATION_FH;
break;
case HAL_JPEG_OPERATION_RCC:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -