UPDATE
I got it to work after discovering something odd, there was a extra 4 bytes getting added when our server got a hold of the data. These 4 bytes disappear if you add a null character to the end of each chunk. My best theory for this is javascript does something with it if no null character is added.
For anyone working with ActiveX controls, particularly TWAIN interface....beware of this depending on what you do with image data.
Original Post So I haven't been successful yet, whenever I have more than one chunk of data to send, it fails. I believe this is a different issue though, at this point I don't believe it is a C++ issue. Sorry if I didn't specify C or C++, I didn't really care one way or the other.
This did lead to me cleaning up the code to read a little bit and realizing if a null was added to the end of the only/last chunk, it worked (all credit to my coworker). Hopefully I'll figure out why the null suddenly makes it work. Thanks everyone.
m_currentImageLength = (int*)malloc(sizeof(int));
encodedBMPData = EncodeImage(hBitmap, info, m_currentImageLength);
//Image will need to be broken up into segments
numOfChunks = (*m_currentImageLength / fiveMBByteSize);
if ( *m_currentImageLength % fiveMBByteSize != 0)
numOfChunks++; //One more chunk for trailing length
encodedCurrentPosition = encodedBMPData;
bytesRemaining = *m_currentImageLength;
segmentedImageData = (char**)malloc(numOfChunks*sizeof(char*));
for(int i = 0; i < numOfChunks; i++)
{
if(bytesRemaining > fiveMBByteSize)
{
segmentedImageData[i] = (char*)malloc(fiveMBByteSize * sizeof(char));
memcpy(segmentedImageData[i], encodedCurrentPosition, fiveMBByteSize);
encodedCurrentPosition += fiveMBByteSize;
bytesRemaining -= fiveMBByteSize;
}
else
{
// Add an extra byte to add null character at end of string for last segment
segmentedImageData[i] = (char*)malloc((bytesRemaining*sizeof(char)) + 1 );
memcpy(segmentedImageData[i], encodedCurrentPosition, bytesRemaining);
segmentedImageData[i][bytesRemaining] = '\0';
break;
}
}
status = PostMessage(this->m_hMasterMessageWnd, WM_IMAGE_SEGMENTED_READY, (WPARAM)&numOfChunks, (LPARAM)segmentedImageData);
free(encodedBMPData);
free(m_currentImageLength);