|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qdebug></qdebug>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "t32bitsrv_wrap.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int t32bitsrv::BufferExchanger::read(const char *srcBuf, int len) {
|
|
Shinya Kitaoka |
120a6e |
m_data = (UCHAR *)memcpy(m_data, srcBuf, len);
|
|
Shinya Kitaoka |
120a6e |
return len;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int t32bitsrv::BufferExchanger::write(char *dstBuf, int len) {
|
|
Shinya Kitaoka |
120a6e |
memcpy(dstBuf, m_data, len);
|
|
Shinya Kitaoka |
120a6e |
m_data += len;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return len;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename pixel=""></typename>
|
|
Shinya Kitaoka |
120a6e |
int t32bitsrv::RasterExchanger<pixel>::read(const char *srcBuf, int len) {</pixel>
|
|
Shinya Kitaoka |
120a6e |
if (m_ras->getWrap() == m_ras->getLx()) {
|
|
Shinya Kitaoka |
120a6e |
memcpy(m_pix, srcBuf, len);
|
|
Shinya Kitaoka |
120a6e |
m_pix = (PIXEL *)((UCHAR *)m_pix + len);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
int xStart = (m_pix - m_ras->pixels(0)) % m_ras->getWrap();
|
|
Shinya Kitaoka |
120a6e |
int remainingData = len;
|
|
Shinya Kitaoka |
120a6e |
int lineData = m_ras->getLx() * sizeof(PIXEL);
|
|
Shinya Kitaoka |
120a6e |
int lineDataToRead = std::min(
|
|
Shinya Kitaoka |
120a6e |
(int)((m_ras->getLx() - xStart) * sizeof(PIXEL)), remainingData);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (; remainingData > 0;
|
|
Shinya Kitaoka |
120a6e |
m_pix += (m_ras->getWrap() - xStart), remainingData -= lineDataToRead,
|
|
Shinya Kitaoka |
120a6e |
lineDataToRead = std::min(lineData, remainingData), xStart = 0)
|
|
Shinya Kitaoka |
120a6e |
memcpy(m_pix, srcBuf, lineDataToRead);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return len;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename pixel=""></typename>
|
|
Shinya Kitaoka |
120a6e |
int t32bitsrv::RasterExchanger<pixel>::write(char *dstBuf, int len) {</pixel>
|
|
Shinya Kitaoka |
120a6e |
// We pass entire pixels, not just bytes
|
|
Shinya Kitaoka |
120a6e |
len = len - (len % sizeof(PIXEL));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_ras->getWrap() == m_ras->getLx()) {
|
|
Shinya Kitaoka |
120a6e |
memcpy(dstBuf, m_pix, len);
|
|
Shinya Kitaoka |
120a6e |
m_pix = (PIXEL *)((UCHAR *)m_pix + len);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
int xStart = (m_pix - m_ras->pixels(0)) % m_ras->getWrap();
|
|
Shinya Kitaoka |
120a6e |
int remainingData = len;
|
|
Shinya Kitaoka |
120a6e |
int lineData = m_ras->getLx() * sizeof(PIXEL);
|
|
Shinya Kitaoka |
120a6e |
int lineDataToWrite = std::min(
|
|
Shinya Kitaoka |
120a6e |
(int)((m_ras->getLx() - xStart) * sizeof(PIXEL)), remainingData);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (; remainingData > 0;
|
|
Shinya Kitaoka |
120a6e |
m_pix += (m_ras->getWrap() - xStart), remainingData -= lineDataToWrite,
|
|
Shinya Kitaoka |
120a6e |
lineDataToWrite = std::min(lineData, remainingData), xStart = 0)
|
|
Shinya Kitaoka |
120a6e |
memcpy(dstBuf, m_pix, lineDataToWrite);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return len;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Explicit specialization of raster exchangers
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI t32bitsrv::RasterExchanger<tpixel32>;</tpixel32>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//================================================================================
|