소스 검색

添加共享内存share Qimage的功能,并编写测试例程。

fujiankuan 4 년 전
부모
커밋
115e6b3e86

+ 9 - 0
src/fusion/fusion_DRG/mainwindow.cpp

@@ -52,6 +52,7 @@ MainWindow::MainWindow(QWidget *parent) :
 
     //发送珊格图的结果
     drgFusion = iv::modulecomm::RegisterSend("drgfusion",160000*30,3);
+    pa = iv::modulecomm::RegisterSend("drg_image",160000*30,3);
 
     QTimer * timer = new QTimer(this);
     connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
@@ -190,6 +191,7 @@ void MainWindow::drawImage()
     painter.restore();
     painter.end();
 
+
     ui->imageLabel->setPixmap(QPixmap::fromImage(image));
 }
 
@@ -213,6 +215,13 @@ void MainWindow::clearImage(){
     }
 #endif
 
+#ifdef APOLLO_FU
+    int nsize = image.byteCount();
+    unsigned char *data  = image.bits();
+    iv::modulecomm::ModuleSendMsg(pa,(const char*)data,nsize);
+#endif
+
+
     ui->imageLabel->setPixmap(QPixmap::fromImage(image));
 }
 

+ 1 - 0
src/fusion/fusion_DRG/mainwindow.h

@@ -43,6 +43,7 @@ private:
     void clearImage();
     void resizeEvent(QResizeEvent* size);
     void * drgFusion;
+    void * pa;
     bool isPreview = true;
 
 private slots:

+ 11 - 0
src/fusion/test_DRG/main.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+
+    return a.exec();
+}

+ 54 - 0
src/fusion/test_DRG/mainwindow.cpp

@@ -0,0 +1,54 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include <QImage>
+#include <iostream>
+
+QImage ximage;
+MainWindow * mw;
+
+char * gbuffer;
+void ListenImage(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    std::cout<<nSize<<std::endl;
+    if(nSize<1) return;
+    if(nSize >= 640000)
+    {
+        memcpy(gbuffer,strdata,640000);
+    }
+    mw->newimage();
+}
+
+
+void MainWindow::UpdateImage(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+    if(nSize >= 640000)
+    {
+        ximage = QImage ((uchar*)strdata,200,800,QImage::Format_ARGB32);
+        ui->label->setPixmap(QPixmap::fromImage(ximage));
+    }
+}
+
+void MainWindow::newimage()
+{
+    emit updateimage();
+}
+
+void MainWindow::drawimage()
+{
+    ximage = QImage ((uchar*)gbuffer,200,800,QImage::Format_ARGB32);
+    ui->label->setPixmap(QPixmap::fromImage(ximage));
+}
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+    gbuffer = new char[640000];
+    ModuleFun funradar =std::bind(&MainWindow::UpdateImage,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    void * pa = iv::modulecomm::RegisterRecvPlus("drg_image",funradar);
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}

+ 31 - 0
src/fusion/test_DRG/mainwindow.h

@@ -0,0 +1,31 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include "modulecomm.h"
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+    void newimage();
+
+private slots:
+    void drawimage();
+signals:
+    void updateimage();
+private:
+    Ui::MainWindow *ui;
+
+    void UpdateImage(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+};
+
+#endif // MAINWINDOW_H

+ 54 - 0
src/fusion/test_DRG/mainwindow.ui

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>827</width>
+    <height>624</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>350</x>
+      <y>40</y>
+      <width>161</width>
+      <height>481</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>TextLabel</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>827</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

+ 38 - 0
src/fusion/test_DRG/test_DRG.pro

@@ -0,0 +1,38 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2021-03-17T15:20:57
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = test_DRG
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+QMAKE_LFLAGS += -no-pie
+
+SOURCES += \
+        main.cpp \
+        mainwindow.cpp
+
+HEADERS += \
+        mainwindow.h
+
+FORMS += \
+        mainwindow.ui
+
+
+INCLUDEPATH += $$PWD/../../../include/
+LIBS += -L$$PWD/../../../bin/ -lxmlparam -lmodulecomm -livlog -livfault