bool CCodecBuffer_RGB888::ReadBlock(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, CMP_BYTE block[], CMP_DWORD dwChannelOffset) { assert(x < GetWidth()); assert(y < GetHeight()); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); CMP_DWORD i, j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { CMP_BYTE* pSrcData = (CMP_BYTE*) (GetData() + ((y + j) * m_dwPitch) + (x * sizeof(nChannelCount))) + dwChannelOffset; for(i = 0; i < dwWidth; i++) { block[(j * w) + i] = *pSrcData; pSrcData += nChannelCount; } // Pad line with previous values if necessary if(i < w) PadLine(i, w, 1, &block[j * w]); } // Pad block with previous values if necessary if(j < h) PadBlock(j, w, h, 1, block); return true; }
bool CCodecBuffer_R8::ReadBlock(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, CMP_BYTE block[]) { assert(x < GetWidth()); assert(y < GetHeight()); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); CMP_DWORD i, j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { CMP_BYTE* pData = (CMP_BYTE*) (GetData() + ((y + j) * m_dwPitch) + (x * nPixelSize)); for(i = 0; i < dwWidth; i++) block[(j * w) + i] = *pData++; // Pad line with previous values if necessary if(i < w) PadLine(i, w, 1, &block[j * w]); } // Pad block with previous values if necessary if(j < h) PadBlock(j, w, h, 1, block); return true; }
bool CCodecBuffer_RGBA16::ReadBlock(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, CMP_WORD wBlock[], CMP_DWORD dwChannelOffset) { assert(x < GetWidth()); assert(y < GetHeight()); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); CMP_DWORD i,j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { CMP_WORD* pData = (CMP_WORD*) (GetData() + ((y + j) * m_dwPitch) + (x * nPixelSize)); for(i = 0; i < dwWidth; i++) { wBlock[(j * w) + i] = pData[dwChannelOffset]; pData += nChannelCount; } // Pad line with previous values if necessary if(i < w) PadLine(i, w, 1, &wBlock[j * w]); } // Pad block with previous values if necessary if(j < h) PadBlock(j, w, h, 1, wBlock); return true; }
bool CCodecBuffer_RGBA16::ReadBlockRGBA(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, CMP_WORD wBlock[]) { assert(x < GetWidth()); assert(y < GetHeight()); assert(x % w == 0); assert(y % h == 0); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); CMP_DWORD i, j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { CMP_WORD* pData = (CMP_WORD*) (GetData() + ((y + j) * m_dwPitch) + (x * nPixelSize)); for(i = 0; i < dwWidth; i++) { memcpy(GET_PIXEL(i, j), pData, nPixelSize); pData += 4; } // Pad line with previous values if necessary if(i < w) PadLine(i, w, 4, &wBlock[j * w * 4]); } // Pad block with previous values if necessary if(j < h) PadBlock(j, w, h, 4, wBlock); return true; }
bool CCodecBuffer_R32F::ReadBlockRGBA(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, float block[]) { assert(x < GetWidth()); assert(y < GetHeight()); assert(x % w == 0); assert(y % h == 0); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); CMP_DWORD i, j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { float* pData = (float*) (GetData() + ((y + j) * m_dwPitch) + (x * nPixelSize)); for(i = 0; i < dwWidth; i++) { float* pDest = GET_PIXEL(i, j); *pDest++ = *pData++; *pDest++ = 0.0f; *pDest++ = 0.0f; *pDest++ = 1.0f; } // Pad line with previous values if necessary if(i < w) PadLine(i, w, 4, &block[j * w * 4]); } // Pad block with previous values if necessary if(j < h) PadBlock(j, w, h, 4, block); return true; }
bool CCodecBuffer_RGB9995EF::ReadBlockRGBA(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, float block[]) { assert(x < GetWidth()); assert(y < GetHeight()); assert(x % w == 0); assert(y % h == 0); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); union { float f; int32_t i; } fi; float Scale = 0.0f; CMP_DWORD i, j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { DWORD* pData = (DWORD*)(GetData() + ((y + j) * m_dwPitch) + (x * nPixelSize)); R9G9B9E5 pTemp; pTemp.rm = ((*pData) & 0x000001ff); pTemp.gm = ((*pData) & 0x0003fe00) >> 9; pTemp.bm = ((*pData) & 0x07fc0000) >> 18; pTemp.e = ((*pData) & 0xf8000000) >> 27; fi.i = 0x33800000 + (pTemp.e << 23); Scale = fi.f; for (i = 0; i < dwWidth; i++) { float* pDest = GET_PIXEL(i, j); *pDest++ = Scale * float(pTemp.rm); *pDest++ = Scale * float(pTemp.gm); *pDest++ = Scale * float(pTemp.bm); *pDest++ = 1.0f; //pData += nChannelCount; } //float* pData = (float*) (GetData() + ((y + j) * m_dwPitch) + (x * nPixelSize)); //for(i = 0; i < dwWidth; i++) //{ // float* pDest = GET_PIXEL(i, j); // *pDest++ = *pData++; // *pDest++ = 0.0f; // *pDest++ = 0.0f; // *pDest++ = 1.0f; //} // Pad line with previous values if necessary if (i < w) PadLine(i, w, 1, &block[j * w]); } // Pad block with previous values if necessary if (j < h) PadBlock(j, w, h, 1, block); return true; }
bool CCodecBuffer_RGB888::ReadBlockRGBA(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, CMP_BYTE block[]) { assert(x < GetWidth()); assert(y < GetHeight()); assert(x % w == 0); assert(y % h == 0); if(x >= GetWidth() || y >= GetHeight()) return false; CMP_DWORD dwWidth = min(w, (GetWidth() - x)); DWORD* pdwBlock = (DWORD*) block; CMP_DWORD i, j; for(j = 0; j < h && (y + j) < GetHeight(); j++) { CMP_BYTE* pSrcData = (CMP_BYTE*) ((GetData() + ((y + j) * m_dwPitch) + (x * nChannelCount))); CMP_BYTE* pDestData = (CMP_BYTE*) &pdwBlock[(j * w)]; for(i = 0; i < dwWidth; i++) { *pDestData++ = *pSrcData++; *pDestData++ = *pSrcData++; *pDestData++ = *pSrcData++; *pDestData++ = 0xff; } // Pad block with previous values if necessary if(i < w) PadLine(i, w, 4, (CMP_BYTE*) &pdwBlock[j * w]); } // Pad block with previous values if necessary if(j < h) PadBlock(j, w, h, 4, (CMP_BYTE*) pdwBlock); return true; }