?? image.c
字號:
*(unsigned long *)(g_pucDictionary + ulBits) = 0;
}
//
// Determine the number of bytes of data to decompress.
//
ulCount = (((lWidth * lBPP) + 7) / 8) * lHeight;
//
// Initialize the pointer into the dictionary.
//
ulIdx = 0;
//
// Start off with no encoding byte.
//
ulBits = 0;
ulByte = 0;
//
// Start from the upper left corner of the image.
//
lX1 = 0;
//
// Loop while there are more rows or more data in the image.
//
while(lHeight && ulCount)
{
//
// See if an encoding byte needs to be read.
//
if(ulBits == 0)
{
//
// Read the encoding byte, which indicates if each of the
// following eight bytes are encoded or literal.
//
ulByte = *pucImage++;
ulBits = 8;
}
//
// See if the next byte is encoded or literal.
//
if(ulByte & (1 << (ulBits - 1)))
{
//
// This byte is encoded, so extract the location and size of
// the encoded data within the dictionary.
//
ulMatch = *pucImage >> 3;
ulSize = (*pucImage++ & 7) + 2;
//
// Decrement the count of bytes to decode by the number of
// copied bytes.
//
ulCount -= ulSize;
}
else
{
//
// This byte is a literal, so copy it into the dictionary.
//
g_pucDictionary[ulIdx++] = *pucImage++;
//
// Decrement the count of bytes to decode.
//
ulCount--;
//
// Clear any previous encoded data information.
//
ulMatch = 0;
ulSize = 0;
}
//
// Loop while there are bytes to copy for the encoded data, or
// once for literal data.
//
while(ulSize || !(ulByte & (1 << (ulBits - 1))))
{
//
// Set the encoded data bit for this data so that this loop
// will only be executed once for literal data.
//
ulByte |= 1 << (ulBits - 1);
//
// Loop while there is more encoded data to copy and there is
// additional space in the dictionary (before the buffer
// wraps).
//
while(ulSize && (ulIdx != sizeof(g_pucDictionary)))
{
//
// Copy this byte.
//
g_pucDictionary[ulIdx] =
g_pucDictionary[(ulIdx + ulMatch) %
sizeof(g_pucDictionary)];
//
// Increment the dictionary pointer.
//
ulIdx++;
//
// Decrement the encoded data size.
//
ulSize--;
}
//
// See if the dictionary pointer is about to wrap, or if there
// is no more data to decompress.
//
if((ulIdx == sizeof(g_pucDictionary)) || !ulCount)
{
//
// Loop through the data in the dictionary buffer.
//
for(ulIdx = 0;
(ulIdx < sizeof(g_pucDictionary)) && lHeight; )
{
//
// Compute the number of pixels that remain in the
// dictionary buffer.
//
ulNum = ((sizeof(g_pucDictionary) - ulIdx) * 8) / lBPP;
//
// See if any of the pixels in the dictionary buffer
// are within the clipping region.
//
if((lY >= pContext->sClipRegion.sYMin) &&
((lX1 + ulNum) >= lX0) && (lX1 <= lX2))
{
//
// Skip some pixels at the start of the scan line
// if required to stay within the clipping region.
//
if(lX1 < lX0)
{
ulIdx += ((lX0 - lX1) * lBPP) / 8;
lX1 = lX0;
}
//
// Shorten the scan line if required to stay within
// the clipping region.
//
if(ulNum > (lX2 - lX1 + 1))
{
ulNum = lX2 - lX1 + 1;
}
//
// Draw this row of image pixels.
//
DpyPixelDrawMultiple(pContext->pDisplay, lX + lX1,
lY, lX1 & 7, ulNum, lBPP,
g_pucDictionary + ulIdx,
pucPalette);
}
//
// Move the X coordinate back to the start of the first
// data byte in this portion of the dictionary buffer.
//
lX1 = ((lX1 * lBPP) & ~7) / lBPP;
//
// See if the remainder of this scan line resides
// within the dictionary buffer.
//
if(((((lWidth - lX1) * lBPP) + 7) / 8) >
(sizeof(g_pucDictionary) - ulIdx))
{
//
// There is more to this scan line than is in the
// dictionary buffer at this point, so move the
// X coordinate by by the number of pixels in the
// dictionary buffer.
//
lX1 += (((sizeof(g_pucDictionary) - ulIdx) * 8) /
lBPP);
//
// The entire dictionary buffer has been scanned.
//
ulIdx = sizeof(g_pucDictionary);
}
else
{
//
// The remainder of this scan line resides in the
// dictionary buffer, so skip past it.
//
ulIdx += (((lWidth - lX1) * lBPP) + 7) / 8;
//
// Move to the start of the next scan line.
//
lX1 = 0;
lY++;
//
// There is one less scan line to process.
//
lHeight--;
}
}
//
// Start over from the beginning of the dictionary buffer.
//
ulIdx = 0;
}
}
//
// Advance to the next bit in the encoding byte.
//
ulBits--;
}
}
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -