📄 haljpeg.c
字号:
//Calculate the scaling rate that we have to use the clip command
if (_bHALJPEGTemp) //rotate
{
/*
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
_fScalingRate = (float)_wJPEGRealHeight * / (float)__wWidth;
else //fit height
_fScalingRate = (float)_wJPEGRealWidth / (float)__wHeight;
*/
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
_wScalingRate = (WORD)((DWORD)_wJPEGRealHeight * 1000L / (DWORD)__wWidth);
else //fit height
_wScalingRate = (WORD)((DWORD)_wJPEGRealWidth * 1000L / (DWORD)__wHeight);
}
else
{
/*
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
_fScalingRate = (float)_wJPEGRealWidth / (float)__wWidth;
else //fit height
_fScalingRate = (float)_wJPEGRealHeight / (float)__wHeight;
*/
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
_wScalingRate = (WORD)((DWORD)_wJPEGRealWidth*1000L/(DWORD)__wWidth);
else //fit height
_wScalingRate = (WORD)((DWORD)_wJPEGRealHeight*1000L/(DWORD)__wHeight);
}
_wJPEGWidth = _wJPEGRealWidth; //Extract the width in the FOrg.
_wJPEGHeight = _wJPEGRealHeight; //Extract the Height in the FOrg.
//Reset the clip region
_JPEGRecoverToNormal();
switch (bZoomMode)
{
case VIEW_ZOOM25:
_bHALJPEGTemp1 = 4;
//_fZoomRate = 0.25;
_bZoomRate = 25;
break;
case VIEW_ZOOM50:
_bHALJPEGTemp1 = 2;
//_fZoomRate = 0.5;
_bZoomRate = 50;
break;
case VIEW_ZOOM100:
_bHALJPEGTemp1 = 1;
//_fZoomRate = 1;
_bZoomRate = 100;
break;
case VIEW_ZOOM150:
//_fZoomRate = 1.5;
_bZoomRate = 150;
break;
case VIEW_ZOOM200:
//_fZoomRate = 2;
_bZoomRate = 200;
break;
default:
break;
}
//if (_fScalingRate < 1)
if (_wScalingRate < 1000)
{
//_bHALJPEGTemp2 = TRUE; //Use clip command to zoom in (zoom out) the image.
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_CLIP_ONLY;
//scaling 100%
__wDisplayWidth = _wJPEGWidth;
__wDisplayHeight = _wJPEGHeight;
if (bZoomMode < VIEW_ZOOM100)
{
if (_bHALJPEGTemp) //Rotate 90
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
if (_wJPEGRealHeight > (__wWidth / _bHALJPEGTemp1)) //scaling down directly.
{
__wDisplayHeight = __wWidth / _bHALJPEGTemp1;
__wDisplayWidth = (WORD)((DWORD)__wDisplayHeight * (DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight);
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_REDECODE;
}
}
else //fit height
{
if (_wJPEGRealWidth > (__wHeight / _bHALJPEGTemp1)) //scaling down directly.
{
__wDisplayWidth = __wHeight / _bHALJPEGTemp1;
__wDisplayHeight = (WORD)((DWORD)__wDisplayWidth * (DWORD)_wJPEGRealHeight / (DWORD)_wJPEGRealWidth);
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_REDECODE;
}
}
}
else
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
if (_wJPEGRealWidth > (__wWidth / _bHALJPEGTemp1)) //scaling down directly.
{
__wDisplayWidth = __wWidth / _bHALJPEGTemp1;
__wDisplayHeight = (WORD)((DWORD)__wDisplayWidth * (DWORD)_wJPEGRealHeight / (DWORD)_wJPEGRealWidth);
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_REDECODE;
}
}
else //fit height
{
if (_wJPEGRealHeight > (__wHeight / _bHALJPEGTemp1)) //scaling down directly.
{
__wDisplayHeight = __wHeight / _bHALJPEGTemp1;
__wDisplayWidth = (WORD)((DWORD)__wDisplayHeight * (DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight);
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_REDECODE;
}
}
}
}
}
else
{
if (bZoomMode <= VIEW_ZOOM100)
{
if (_bHALJPEGTemp) //rotate
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
__wDisplayHeight = __wWidth / _bHALJPEGTemp1;
else
__wDisplayWidth = __wHeight / _bHALJPEGTemp1;
}
else
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
__wDisplayWidth = __wWidth / _bHALJPEGTemp1;
else
__wDisplayHeight = __wHeight / _bHALJPEGTemp1;
}
}
else
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
if (_bHALJPEGTemp) //rotate
{
if (_wJPEGRealHeight < __wHALJPEGDisplayBufWidth)
__wDisplayHeight = _wJPEGRealHeight;
else
__wDisplayHeight = __wHALJPEGDisplayBufWidth;
}
else
{
if (_wJPEGRealWidth < __wHALJPEGDisplayBufWidth)
__wDisplayWidth = _wJPEGRealWidth;
else
__wDisplayWidth = __wHALJPEGDisplayBufWidth;
}
}
else //fit height
{
if (_bHALJPEGTemp) //rotate
{
if (_wJPEGRealWidth < __wHALJPEGDisplayBufHeight)
__wDisplayWidth = _wJPEGRealWidth;
else
__wDisplayWidth = __wHALJPEGDisplayBufHeight;
}
else
{
if (_wJPEGRealHeight < __wHALJPEGDisplayBufHeight)
__wDisplayHeight = _wJPEGRealHeight;
else
__wDisplayHeight = __wHALJPEGDisplayBufHeight;
}
}
}
_ForceTo8Multiple(&__wDisplayWidth);
_ForceTo8Multiple(&__wDisplayHeight);
if (_bHALJPEGTemp) //Rotate 90
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
__wDisplayWidth = (WORD)((DWORD)__wDisplayHeight * (DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight);
else //fit height
__wDisplayHeight = (WORD)((DWORD)__wDisplayWidth * (DWORD)_wJPEGRealHeight / (DWORD)_wJPEGRealWidth);
}
else
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
__wDisplayHeight = (WORD)((DWORD)__wDisplayWidth * (DWORD)_wJPEGRealHeight / (DWORD)_wJPEGRealWidth);
else //fit height
__wDisplayWidth = (WORD)((DWORD)__wDisplayHeight * (DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight);
}
}
_ForceTo8Multiple(&__wDisplayWidth);
_ForceTo8Multiple(&__wDisplayHeight);
__wHExtractStart = 0; //Extract the image from the starting position of the FOrg.
__wVExtractStart = 0; //Extract the image from the starting position of the FOrg.
//if (_fScalingRate < 1)
if (_wScalingRate < 1000)
{
if (!__bThumbnailMode) //CoCo1.00, The thumbnail mode can't use clip command to zoom in the picture to feet the displaying rectangle.
{
if (_bHALJPEGTemp2 == HAL_JPEG_SCALING_RESULT_CLIP_ONLY) //Use clip command to do zoom in or zoom out.
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
if (_bHALJPEGTemp) //rotate
{
//__wHClipWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth * (DWORD)__wDisplayHeight / (DWORD)__wWidth) / _fZoomRate);
__wHClipWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)__wDisplayHeight*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHClipWidth * (DWORD)__wDisplayWidth / (DWORD)__wDisplayHeight);
}
else
{
//__wHClipWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth * (DWORD)__wDisplayWidth / (DWORD)__wWidth) / _fZoomRate);
__wHClipWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)__wDisplayWidth*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHClipWidth * (DWORD)__wDisplayHeight / (DWORD)__wDisplayWidth);
}
}
else //fit height
{
if (_bHALJPEGTemp) //rotate
//__wVClipHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)__wDisplayWidth / (DWORD)__wHeight) / _fZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)__wDisplayWidth*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
else
//__wVClipHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)__wDisplayHeight / (DWORD)__wHeight) / _fZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)__wDisplayHeight*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
__wHClipWidth = (WORD)((DWORD)__wVClipHeight * (DWORD)__wHALJPEGDisplayBufWidth / (DWORD)__wHALJPEGDisplayBufHeight);
}
__wHClipStart = (__wHALJPEGDisplayBufWidth - __wHClipWidth) >> 1;
__wVClipStart = (__wHALJPEGDisplayBufHeight - __wVClipHeight) >> 1;
}
}
}
else
{
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_REDECODE;
if (bZoomMode > VIEW_ZOOM100)
{
//Calculate the width and height of the clip region.
//if (_fScalingRate < _fZoomRate)
if (_wScalingRate < (WORD)_bZoomRate*10)
{
//First, extract image by decode command. Second, clip it to fit the zoom rate.
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
if (_bHALJPEGTemp) //Rotate 90
{
if (__wDisplayHeight < __wHALJPEGDisplayBufWidth)
//__wHClipWidth = (DWORD)((float)__wHALJPEGDisplayBufWidth / _fZoomRate);
__wHClipWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*100L/(DWORD)_bZoomRate);
else
//__wHClipWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth * (DWORD)__wHALJPEGDisplayBufWidth / (DWORD)__wWidth) / _fZoomRate);
__wHClipWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)__wHALJPEGDisplayBufWidth*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
}
else
{
if (__wDisplayWidth < __wHALJPEGDisplayBufWidth)
//__wHClipWidth = (DWORD)((float)__wHALJPEGDisplayBufWidth / _fZoomRate);
__wHClipWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*100L/(DWORD)_bZoomRate);
else
//__wHClipWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth * (DWORD)__wHALJPEGDisplayBufWidth / (DWORD)__wWidth) / _fZoomRate);
__wHClipWidth = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)__wHALJPEGDisplayBufWidth*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
}
__wVClipHeight = (WORD)((DWORD)__wHClipWidth * (DWORD)__wHALJPEGDisplayBufHeight / (DWORD)__wHALJPEGDisplayBufWidth);
}
else
{
if (_bHALJPEGTemp) //Rotate 90
{
if (__wDisplayWidth < __wHALJPEGDisplayBufHeight)
//__wVClipHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealWidth/(DWORD)__wHeight)/_fZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealWidth*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
else
//__wVClipHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)__wHALJPEGDisplayBufHeight / (DWORD)__wHeight) / _fZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)__wHALJPEGDisplayBufHeight*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
}
else
{
if (__wDisplayHeight < __wHALJPEGDisplayBufHeight)
//__wVClipHeight = (DWORD)((float)__wHALJPEGDisplayBufHeight / _fZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*100L/(DWORD)_bZoomRate);
else
//__wVClipHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)__wHALJPEGDisplayBufHeight / (DWORD)__wHeight) / _fZoomRate);
__wVClipHeight = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)__wHALJPEGDisplayBufHeight*100L/(DWORD)__wHeight/(DWORD)_bZoomRate);
}
__wHClipWidth = (WORD)((DWORD)__wVClipHeight * (DWORD)__wHALJPEGDisplayBufWidth / (DWORD)__wHALJPEGDisplayBufHeight);
}
__wHClipStart = (__wHALJPEGDisplayBufWidth - __wHClipWidth) >> 1;
__wVClipStart = (__wHALJPEGDisplayBufHeight - __wVClipHeight) >> 1;
_bHALJPEGTemp2 = HAL_JPEG_SCALING_RESULT_REDECODE;
}
else
{
_bScalingAll = FALSE;
//Calculate the width and height of the picture that we want to extract from FOrg.
if (_bHALJPEGTemp) //Rotate 90
{
if (_bJPEGfit == HAL_JPEG_DISPLAY_FIT_WIDTH) // fit width
{
//if (((DWORD)(((float)((DWORD)__wWidth*(DWORD)_wJPEGRealWidth)*_fZoomRate)) / (DWORD)_wJPEGRealHeight) > __wHALJPEGDisplayBufHeight)
if (((DWORD)__wWidth*(DWORD)_wJPEGRealWidth*(DWORD)_bZoomRate/100L/(DWORD)_wJPEGRealHeight) > (DWORD)__wHALJPEGDisplayBufHeight)
{
//fill the whole screen to prevent the black region
__wDisplayWidth = __wHALJPEGDisplayBufHeight;
//_wJPEGWidth = (WORD)((float)((DWORD)__wHALJPEGDisplayBufHeight * (DWORD)_wJPEGRealHeight / (DWORD)__wWidth) / _fZoomRate);
_wJPEGWidth = (WORD)((DWORD)__wHALJPEGDisplayBufHeight*(DWORD)_wJPEGRealHeight/(DWORD)__wWidth*100L/(DWORD)_bZoomRate);
}
else
//__wDisplayWidth = (WORD)((float)((DWORD)__wWidth * (DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight)*_fZoomRate);
__wDisplayWidth = (WORD)((DWORD)__wWidth*(DWORD)_wJPEGRealWidth / (DWORD)_wJPEGRealHeight*(DWORD)_bZoomRate/100L);
//_wJPEGHeight = (WORD)((float)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealHeight / (DWORD)__wWidth) / _fZoomRate);
_wJPEGHeight = (WORD)((DWORD)__wHALJPEGDisplayBufWidth*(DWORD)_wJPEGRealHeight*100L/(DWORD)__wWidth/(DWORD)_bZoomRate);
}
else //fit height
{
//if (((DWORD)(((float)((DWORD)__wHeight*(DWORD)_wJPEGRealHeight)*_fZoomRate)) / (DWORD)_wJPEGRealWidth) > __wHALJPEGDisplayBufWidth)
if (((DWORD)__wHeight*(DWORD)_wJPEGRealHeight*(DWORD)_bZoomRate/100L/(DWORD)_wJPEGRealWidth) > (DWORD)__wHALJPEGDisplayBufWidth)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -