return true;
}
+//
+// Fill in a DMbuffer with data.
+//
+// NOTE: The caller must make sure that the buffer size is no less
+// than (nRows * rowSize).
+//
+
+bool
+IrixDMIC_RawToJpeg::copyToBuffer(DMbuffer buf, const void *data,
+ int rowSize, int nRows, int stride)
+{
+ char *dataBytes = (char *)data;
+ char *bufPtr = (char *)dmBufferMapData(buf);
+ for (int i = 0; i < nRows; i++) {
+ memcpy(bufPtr, &dataBytes[i * stride], rowSize);
+ bufPtr += rowSize;
+ }
+
+ if (dmBufferSetSize(buf, nRows * rowSize) != DM_SUCCESS) {
+ reportError("dmBufferSetSize");
+ return false;
+ }
+
+ return true;
+}
+
//
// Map DMbuffer to physical memory.
//
static bool allocBuffer(DMbuffer *pbuf, DMbufferpool pool);
static bool copyToBuffer(DMbuffer buf, const void *data, int dataSize);
+ static bool copyToBuffer(DMbuffer buf, const void *data,
+ int rowSize, int nRows, int stride);
static int getBufferSize(DMbuffer buf);
static void * mapBufferData(DMbuffer buf);
static void freeBuffer(DMbuffer buf);
if (!m_ic.allocBuffer(&srcBuf, m_srcPool)) {
return;
}
- // FIXME: Currently, copyToBuffer() copies parts of the image incorrectly.
- if (!m_ic.copyToBuffer(srcBuf, buf, w * h * (fmt->bpp / 8))) {
+ int widthInBytes = w * (fmt->bpp / 8);
+ int strideInBytes = stride * (fmt->bpp / 8);
+ if (!m_ic.copyToBuffer(srcBuf, buf, widthInBytes, h, strideInBytes)) {
m_ic.freeBuffer(srcBuf);
return;
}