Fix data transmission to FPGA when file size is not exactly 16384 bytes

Fix input image display
master
Timothy Pearson 12 years ago
parent 84b137a12b
commit 98d8958426

@ -1440,20 +1440,27 @@ void FPGAViewPart::updateDisplay() {
m_dataByteArray = file.readAll();
}
else {
// Show image in GUI
TQPixmap inputImagePixmap(m_dataInputImage);
m_base->ImageInputLabel->setPixmap(inputImagePixmap);
m_inputImageViewer->setPixmap(inputImagePixmap);
// Populate m_dataByteArray with image data
// Create grayscale input image buffer
TQImage displayImage = m_dataInputImage;
// Populate m_dataByteArray and displayImage with image data
int x;
int y;
unsigned char pixel_value;
int imageWidth = m_dataInputImage.width();
m_dataByteArray.resize(m_dataInputImage.height()*imageWidth);
for (y=0; y<m_dataInputImage.height(); y++) {
for (x=0; x<m_dataInputImage.width(); x++) {
m_dataByteArray[(y*imageWidth)+x] = tqGray(m_dataInputImage.pixel(x,y));
pixel_value = tqGray(m_dataInputImage.pixel(x,y));
m_dataByteArray[(y*imageWidth)+x] = pixel_value;
displayImage.setPixel(x, y, tqRgb(pixel_value, pixel_value, pixel_value));
}
}
// Show image in GUI
TQPixmap inputImagePixmap(displayImage);
m_base->ImageInputLabel->setPixmap(inputImagePixmap);
m_inputImageViewer->setPixmap(inputImagePixmap);
}
m_base->dataProcessingStatusLabel->setText(i18n("Transmitting data to FPGA") + "...");
@ -1462,18 +1469,23 @@ void FPGAViewPart::updateDisplay() {
m_socket->writeBlock("M\r", 2);
m_socket->writeBufferedData();
int len = m_dataByteArray.size();
if (len >= 16384) {
len = 16384;
int txlen = 16384;
if (len >= txlen) {
len = txlen;
}
TQByteArray dataToSend(16384*2);
for (i=0; i<len; i++) {
dataToSend[(i*2)+0] = m_dataByteArray[i];
dataToSend[(i*2)+1] = '\r';
}
m_base->dataProcessingProgressBar->setTotalSteps(len*4);
for (; i<txlen; i++) {
dataToSend[(i*2)+0] = 0;
dataToSend[(i*2)+1] = '\r';
}
m_base->dataProcessingProgressBar->setTotalSteps(txlen*4);
m_base->dataProcessingProgressBar->setProgress(0);
int offset = 0;
while (offset < (len*2)) {
while (offset < (txlen*2)) {
m_socket->writeBlock(dataToSend.data()+offset, 1024);
m_socket->writeBufferedData();
offset = offset + 1024;

Loading…
Cancel
Save