qtcpsocket send and recieve image

Qt QImage 显示TIFF格式图片 以3通道图像为例,位深度 显示96位,意思是 一个像素,可以显示的颜色范围为2的96次方种,每个通道32位,也就是4个字节。利用Qt 控件 显示 tiff 图片,由于tiff图像深度位96位,3通道,所以无法直接用QImage 显示,QImage 支持24位,因此需要利用Opencv 进行转换。(5),最后建议使用 QGraphicsView 显示 QImage 这样可以进行缩放,更利用观看。(2),加载后进行 规一化,然后进行位深 转换,将32f 转成8u。 阅读详情
点击打开链接
Hi All, 

I have two simple applications which are network based. The 'server'
takes a screenshot of its computer. When a 'client' connects, it will
receive the captured image. These are basically the fortune
server/client examples modified to transmit images instead of text.

Here is my code for sending the image:

      QByteArray block; 

    QDataStream out(&block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_0);
    out << (quint16)0;
    out << originalPixmap;
    qDebug() << "Pixmap Sent";
    out.device()->seek(0);
    out << (quint16)(block.size() - sizeof(quint16));
    QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
    connect(clientConnection, SIGNAL(disconnected()),
            clientConnection, SLOT(deleteLater()));
    clientConnection->write(block);
    clientConnection->disconnectFromHost();


And here is my code for reading it

     QDataStream in(tcpSocket); 

    in.setVersion(QDataStream::Qt_4_0);
    if (blockSize == 0) {
    if (tcpSocket->bytesAvailable() < (int)sizeof(quint64))
            return;
        in >> blockSize;
    }
    if (tcpSocket->bytesAvailable() < blockSize)
        return;
    QPixmap nextPixmap;
    in >> nextPixmap;
    originalPixmap = currentPixmap;
    updateScreenshotLabel();
    getFortuneButton->setEnabled(true);
    received = false;


 
 
 

The client receives some data, but how to I:
    1. Ensure that all of the sent data is received, and
    2. Convert the received data into a QPixmap so that it can be
displayed.

I know it sounds simple but i have racked  my brains for several days
now and I just cant seem to get it. Please assist.

Thank you in advance,

Joshua W.

 

I am getting these errors:
QPixmap::scaled: Pixmap is a null pixmap 

QSize(-1, -1) 

QImage/QPixmap加载图片失败的两种解决方法 在上面的代码中,首先指定Qt插件的路径,然后使用QImageReader::supportedImageFormats()函数获取支持的图片格式列表。接下来,使用QPluginLoader加载每个格式对应的插件,并使用load()函数检查加载是否成功。通过以上两种解决方法,我们可以有效地解决QImage/QPixmap加载图片失败的问题。在QT中,使用QImage和QPixmap类加载图片是非常常见的操作。另外,还要确保图片文件的格式是被QT支持的格式,如PNG、JPEG等。解决方法二:检查Qt插件。 阅读详情

相关推荐

systermverilog中for循环中的fork join执行情况分析

仅为本人学习记录,如有错误感谢指正!

qq_63807221的博客 1461

QT 中遇到QPixmap::scaled: Pixmap is a null pixmap 的解决办法

我的文件名设为03.gif时遇到QPixmap::scaled: Pixmap is a null pixmap,不能显示 这种情况下只需将文件名改为英文形式即可。 /*播放动画*/ movie=new QMovie(this); movie->setFileName("../03bomb/bomb.gif"); ui->label->setMovi...

小魚兒 1万+

(25.08)Ubuntu20.04+ROS1复现FAST-LIO2

请确保在。

m0_69023437的博客 3994

qtcpsocket send and recieve the image from youself

点击打开链接 Thanks alot all of you, especially Thiago, I finally got it working. The trick was to read the data after the QTcpSocket connection was closed rather than reading it when readyRead() wa

Qicz的学习笔记 博客新址:izcqi.com 833

mtk-drm初始化

mtk-drm初始化走读

zhexingsunba的博客 4932

基于结构的虚拟筛选模型 gnina 从源码编译

所需要的软件安装包: 安装 CUDA 装的时候看着点,第二个要你装驱动的选择,回答N,不装。 sudo sh cuda_10.0.130_410.48_linux.run sudo vim ~/.bashrc 在 ~/.bashrc 文件最后加上 export PATH=/usr/bin:/usr/local/cuda-10.0/bin${PATH} export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:${LD_LIBRARY_PATH} source ~

周迪新的博客 3188

STM32C5深度解析:Cortex-M33内核与CAN-FD外设的实战选型指南

MCU选型中,内核架构与外设资源是决定系统性能与成本的关键。Cortex-M33内核在指令效率、中断响应和TrustZone安全扩展上较前代显著提升,配合CAN-FD、高精度ADC等外设,可满足工业控制与物联网终端对实时通信和数据处理的需求。STM32C5正是基于这一架构的主流级通用MCU,在性能、外设、价格与生态间取得均衡,适合F103/G030升级及新项目选型。

weixin_34262482的博客 162

用scons编译STM32F103工程

想用vscode来实现代码的编辑与调试代码,原先这个工程是用STM32CUBEIDE建立的,参照STM32CUBEIDE的编译过程,编写了下面的scons脚本,scons是初次了解,既然是python脚本,那么会什么就怎么写吧。 import os import sys import glob cross_compiler_prefix = 'arm-none-eabi-' CC = cross_compiler_prefix+'gcc' CXX = cross_compiler_prefix+'g+

cylinc的专栏 1623

QImage::scaled: Image is a null image--PySIde2和PyQt5无法显示jpg等图像

问题 使用PySIde2和PyQt5输出显示图像是,提示如下问题,当图像路径等都正确时。 QImage::scaled: Image is a null image 解决 此问题的主要原因是,PySIde2和PyQt5没有找到相应的dll文件,使用QtGui.QImageReader.supportedImageFormats()可以显示当前支持的文件格式。 在代码中头部添加如下内容,可以解决。...

u012921982的博客 4797

FPGA/IC 秋招笔试/面试题总结(续)

FPGA/IC 秋招笔试/面试题总结(续)来啦… 文章目录二十七、状态机1. Moore/Mealy状态机2.一、二、三段式状态机 二十七、状态机 1. Moore/Mealy状态机 (1)Moore状态机: 输出只由当前状态决定,即次态=f(现态。输入),输出=f(现态) Moore型状态机的输出信号是直接由状态寄存器译码得到的。 Moore型状态机检测序列1101如下 Moore型状态机输出函数只由状态变量决定,想要输出Z=1,必须S4状态形成,即寄存器中的1101都打进去后才可以。输出Z=1会在

Crazzy_M的博客 2万+

【图像超分】论文精读:Interpreting Super-Resolution Networks with Local Attribution Maps(LAM)

论文题目:Interpreting Super-Resolution Networks with Local Attribution Maps —— 用局部归因图解释超分辨率网络CVPR 2021!必读文章!必须会的可视化手段!很多文章中都会对比LAM!图像超分辨率 (SR) 技术发展迅速,受益于深度网络的发明及其连续突破。然而,众所周知,深度学习和深度神经网络很难解释。SR网络继承了这种神秘的性质,很少有作品试图理解它们。在本文中,我们对 SR 网络进行了归因分析。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 547

[QT]问题记录-QPixmap::scaled 缩放不成功

解答的帖子:http://bbs.youkuaiyun.com/topics/391850818 使用 pix.scaled(400,400) 之后需要将图片返回就可以了. 转载于:https://www.cnblogs.com/ourran/p/6867473.html

weixin_30595035的博客 1213

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

2021-07-22

使用Qt加载动画的时候,报QPixmap::scaled: Pixmap is a null pixmap错误,我的代码如下所示: BlockAnimation::BlockAnimation(QWidget* parent /*= nullptr*/): QWidget(parent),m_pGifUi(new Ui::Form) { m_pGifUi->setupUi(this); setAttribute(Qt::WA_ShowModal); m_pGifUi-&

qq_45490578的博客 784

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

【Qt】QPixmap按比例缩放图片。

QPixmap QPixmap::scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation) Qt::AspectRatioMode aspectRatioMode: Qt::IgnoreAspectRatio 忽略图片比例,直接缩放到size(图中-...

momodosky的博客 1万+

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

QT使用QLabel控件显示图片,报错:QPixmap::scaled: Pixmap is a null pixmap

QT使用QLabel控件显示图片,报错:QPixmap::scaled: Pixmap is a null pixmap,将图片位深改成32位。

weixin_45868764的博客 6794

QT使用TCP传输图像或者数据的方法

客户端QTCPsocket使用方法 加qmake到工程pro:把 Qtcpsocket用到的qmake 也就是 network 加到我们原来的pro文件中 QT += core gui network 同时也不要忘记包含头文件 #include <QTcpSocket> 然后在类里面创建一个指针变量,不要忘记在构造函数中new一下哦,指针不同于普通变量,我们需要new一下为他分配地址空间的。 QTcpSocket *tcpsocket; tcpsocket = new QTc

ALong_Lj的博客 1万+

QT中用socket接收图像数据(JPEG)后立即解码显示

最近在做一个小程序,功能很简单,就是从socket传回jpeg格式的数据,然后在本机上显示出来,当然这个过程并没有保存收到的数据后再显示,而是收到数据后马上显示。 这里采用了OPENCV中的解码函数: imdecode(); 这个函数的用法比较烦,但也不复杂,如下: 这是一个接收socket信号的函数(中间还有一个自定义的信号,这个不是重点) void MainWindow::readD

tenyee 8121

QTcpSocket 使用QDataStream 发送和保存图片文件

图片文件 现在遇到的问题是writeRawData()读取大文件时程序崩溃,思路是分多次进行读取和发送,待写 发送端 qDebug()&amp;amp;lt;&amp;amp;lt;&amp;quot;start to find pix&amp;quot;&amp;amp;lt;&amp;amp;lt;endl; QImage pic(&amp;quot;D:/svn//timg.jpg&amp;quot;); if(pic.

叶落随风 6714
上一篇: jquery 动态图片
下一篇: qtcpsocket send and recieve the image from youself
Qicz
博客等级 码龄16年 56粉丝 122原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值