From 98d8958426c8dd3a77c7838722d819a4197b72b7 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 23 Mar 2013 15:46:31 -0500 Subject: [PATCH] Fix data transmission to FPGA when file size is not exactly 16384 bytes Fix input image display --- clients/tde/src/part/fpgaview/part.cpp | 32 ++++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp index 7aa3f2b..c312c66 100644 --- a/clients/tde/src/part/fpgaview/part.cpp +++ b/clients/tde/src/part/fpgaview/part.cpp @@ -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; yImageInputLabel->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; idataProcessingProgressBar->setTotalSteps(len*4); + for (; idataProcessingProgressBar->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;