diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-03-23 15:46:31 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-03-23 15:46:31 -0500 |
commit | 98d8958426c8dd3a77c7838722d819a4197b72b7 (patch) | |
tree | bc2558db04050f903183f734e16168a7e41c5842 /clients/tde/src/part/fpgaview | |
parent | 84b137a12bee6d656252582f56be903e8b0f6c3f (diff) | |
download | ulab-98d8958426c8dd3a77c7838722d819a4197b72b7.tar.gz ulab-98d8958426c8dd3a77c7838722d819a4197b72b7.zip |
Fix data transmission to FPGA when file size is not exactly 16384 bytes
Fix input image display
Diffstat (limited to 'clients/tde/src/part/fpgaview')
-rw-r--r-- | clients/tde/src/part/fpgaview/part.cpp | 32 |
1 files 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; 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; |