当前位置: 首页 > news >正文

网站建设需要多久免费推广工具有哪些

网站建设需要多久,免费推广工具有哪些,代运营公司是做什么的,东莞网站主页制作很久以前,我写过一遍文章来介绍 HImage 和 QImage 之间的转换方法。(https://blog.csdn.net/liyuanbhu/article/details/91356988) 这个代码其实是有些问题的。因为我们知道 QImage 中的图像数据不一定是连续的,尤其是图像的宽度…

很久以前,我写过一遍文章来介绍 HImage 和 QImage 之间的转换方法。(https://blog.csdn.net/liyuanbhu/article/details/91356988)

这个代码其实是有些问题的。因为我们知道 QImage 中的图像数据不一定是连续的,尤其是图像的宽度是奇数时,每行数据后面基本都会多填充几个字节将每行的字节数凑成4的整倍数。

HImage 内部如何存储我不是很确定。但是GenImage1() 函数,GenImage3() 函数和 GenImageInterleaved() 函数里面输入图像数据都要求是连续的。因此,如果不判断QImage 的数据是否连续,直接将图像数据传过来有可能获得的图像是错误的。

本来我懒得写这篇博客。但是这么多年过去了。在网上搜相关的代码,竟然还是没有一个代码是正确考虑这个问题的。中文互联网上技术博客水平之低真是令人瞠目。

所以我还是写一写这个问题,避免大家重复的遇到这个 bug 吧。

首先是将 QImage 转换为 HImage 的代码。与原来的代码相比,就是在每种图像类型转换时增加了个判断。如果QImage 图像数据不是连续的,那么就一行一行的拷贝数据。

#include "himageqimage.h"
#include <QDebug>
using namespace HalconCpp;/*** @brief QImage2HImage 将 Qt QImage 转换为 Halcon 的 HImage* @param from 输入的 QImage* @param to 输出的 HImage ,from 和 to 不共享内存数据。 每次都会为 to 重新分配内存。* @return true 表示转换成功,false 表示转换失败。*/
bool QImage2HImage(QImage &from, HalconCpp::HImage &to)
{if(from.isNull()) return false;int width = from.width(), height = from.height();QImage::Format format = from.format();if(format == QImage::Format_RGB32 ||format == QImage::Format_ARGB32 ||format == QImage::Format_ARGB32_Premultiplied){if(from.bytesPerLine() == 4 * width){to.GenImageInterleaved(from.bits(), "bgrx", width, height, 0,  "byte", width, height, 0, 0, 8, 0);}else{to.GenImageInterleaved(from.bits(), "bgrx", width, height, 0,  "byte", width, height, 0, 0, 8, 0);uchar *R, *G, *B;HString Type;Hlong Width, Height;to.GetImagePointer3(reinterpret_cast<void **>(&R),reinterpret_cast<void **>(&G),reinterpret_cast<void **>(&B), &Type, &Width, &Height);for(int row = 0; row < height; row ++){QRgb* line = reinterpret_cast<QRgb*>(from.scanLine(row));for(int col = 0; col < width; col ++){*R = qRed(line[col]);*G = qGreen(line[col]);*B = qBlue(line[col]);++R;++G;++B;}}}return true;}else if(format == QImage::Format_RGB888){if(from.bytesPerLine() == 3 * width){to.GenImageInterleaved(from.bits(), "rgb", width, height, 0,  "byte", width, height, 0, 0, 8, 0);}else{to.GenImageInterleaved(from.bits(), "rgb", width, height, 0,  "byte", width, height, 0, 0, 8, 0);uchar *R, *G, *B;HString Type;Hlong Width, Height;to.GetImagePointer3(reinterpret_cast<void **>(&R),reinterpret_cast<void **>(&G),reinterpret_cast<void **>(&B), &Type, &Width, &Height);for(int row = 0; row < height; row ++){unsigned char* line = reinterpret_cast<unsigned char *>(from.scanLine(row));for(int col = 0; col < width; col ++){*R ++ = *line ++;*G ++ = *line ++;*B ++ = *line ++;}}}return true;}else if(format == QImage::Format_Grayscale8 || format == QImage::Format_Indexed8){if(from.bytesPerLine() == width){to.GenImage1("byte", width, height, from.bits());}else// 这时说明每行数据之间有填充字节。因此需要重新写数据{to.GenImageConst("byte", width, height);Hlong W, H; HString Type;unsigned char * pTo = reinterpret_cast<unsigned char *>( to.GetImagePointer1(&Type, &W, &H) );for(int row = 1; row < H; row ++){const unsigned char * pSrc = from.constScanLine(row);unsigned char * pDist = pTo + row * W;memcpy( pDist, pSrc, static_cast<size_t>(W));}}return true;}return false;
}

下面是 HImage 转 QImage。基本原理也是相同的。拷贝数据之前判断一下QImage 数据是否连续。不连续就一行一行的处理。

/*** @brief HImage2QImage 将 Halcon 的 HImage 转换为 Qt 的 QImage* @param from HImage ,暂时只支持 8bits 灰度图像和 8bits 的 3 通道彩色图像* @param to QImage ,这里 from 和 to 不共享内存。如果 to 的内存大小合适,那么就不用重新分配内存。所以可以加快速度。* @return  true 表示转换成功,false 表示转换失败*/
bool HImage2QImage(HalconCpp::HImage &from, QImage &to)
{Hlong width;Hlong height;from.GetImageSize(&width, &height);HTuple channels = from.CountChannels();HTuple type = from.GetImageType();if( strcmp(type[0].S(), "byte" )) // 如果不是 byte 类型,则失败{return false;}QImage::Format format;switch(channels[0].I()){case 1:format = QImage::Format_Grayscale8;break;case 3:format = QImage::Format_RGB888;break;default:return false;}if(to.width() != width || to.height() != height || to.format() != format){to = QImage(static_cast<int>(width),static_cast<int>(height),format);}HString Type;if(channels[0].I() == 1){unsigned char * pSrc = reinterpret_cast<unsigned char *>( from.GetImagePointer1(&Type, &width, &height) );if(to.bytesPerLine() == width){memcpy( to.bits(), pSrc, static_cast<size_t>(width) * static_cast<size_t>(height) );}else{for(int row = 1; row < height; row ++){unsigned char * pDistLine = to.scanLine(row);const unsigned char * pSrcLine = pSrc + row * width;memcpy( pDistLine, pSrcLine, static_cast<size_t>(width));}}return true;}else if(channels[0].I() == 3){uchar *R, *G, *B;from.GetImagePointer3(reinterpret_cast<void **>(&R),reinterpret_cast<void **>(&G),reinterpret_cast<void **>(&B), &Type, &width, &height);for(int row = 0; row < height; row ++){unsigned char * line = reinterpret_cast<unsigned char *>(to.scanLine(row));for(int col = 0; col < width; col ++){*line++ = *R++;*line++ = *G++;*line++ = *B++;}}return true;}return false;
}

文章转载自:
http://dinncoichthyophagous.zfyr.cn
http://dinncorochet.zfyr.cn
http://dinncophysical.zfyr.cn
http://dinncosuperduper.zfyr.cn
http://dinncojimjams.zfyr.cn
http://dinncorigescent.zfyr.cn
http://dinncocolic.zfyr.cn
http://dinncocoagula.zfyr.cn
http://dinncowellerism.zfyr.cn
http://dinncoeuryphage.zfyr.cn
http://dinncounclarity.zfyr.cn
http://dinncokinesiatrics.zfyr.cn
http://dinncotzetze.zfyr.cn
http://dinnconovel.zfyr.cn
http://dinncowhose.zfyr.cn
http://dinncosissy.zfyr.cn
http://dinncosassenach.zfyr.cn
http://dinncoenthronement.zfyr.cn
http://dinncocommerce.zfyr.cn
http://dinncovolitant.zfyr.cn
http://dinncoweel.zfyr.cn
http://dinncobackwoodsy.zfyr.cn
http://dinncoululance.zfyr.cn
http://dinncoretribalize.zfyr.cn
http://dinncoarcanum.zfyr.cn
http://dinncoputti.zfyr.cn
http://dinncolng.zfyr.cn
http://dinncowheeled.zfyr.cn
http://dinncoregretfully.zfyr.cn
http://dinncolawrenciana.zfyr.cn
http://dinncofopling.zfyr.cn
http://dinncotailforemost.zfyr.cn
http://dinnconilometer.zfyr.cn
http://dinncoantitank.zfyr.cn
http://dinncosandy.zfyr.cn
http://dinncohexenbesen.zfyr.cn
http://dinncolasher.zfyr.cn
http://dinncoeternize.zfyr.cn
http://dinncomacrophyte.zfyr.cn
http://dinncoballadist.zfyr.cn
http://dinncosprocket.zfyr.cn
http://dinncounseriousness.zfyr.cn
http://dinncometabolize.zfyr.cn
http://dinncojoey.zfyr.cn
http://dinncosubring.zfyr.cn
http://dinncoaeriality.zfyr.cn
http://dinncoguam.zfyr.cn
http://dinncoborsch.zfyr.cn
http://dinncopyrocellulose.zfyr.cn
http://dinncobernie.zfyr.cn
http://dinncowadeable.zfyr.cn
http://dinncounmilitary.zfyr.cn
http://dinncoccw.zfyr.cn
http://dinncohaulyard.zfyr.cn
http://dinncodissident.zfyr.cn
http://dinncoescargot.zfyr.cn
http://dinncopolygenesis.zfyr.cn
http://dinncodidact.zfyr.cn
http://dinncotupek.zfyr.cn
http://dinncophantasize.zfyr.cn
http://dinncoengrave.zfyr.cn
http://dinncoknaggy.zfyr.cn
http://dinncohenna.zfyr.cn
http://dinncopungent.zfyr.cn
http://dinncoretzina.zfyr.cn
http://dinncoovereaten.zfyr.cn
http://dinncopumiceous.zfyr.cn
http://dinncouninucleate.zfyr.cn
http://dinncoutricular.zfyr.cn
http://dinncoenvoi.zfyr.cn
http://dinncoloun.zfyr.cn
http://dinncovoluntarily.zfyr.cn
http://dinncoclearing.zfyr.cn
http://dinncoregermination.zfyr.cn
http://dinncopathological.zfyr.cn
http://dinncocornettist.zfyr.cn
http://dinncocrimea.zfyr.cn
http://dinncotanjungpriok.zfyr.cn
http://dinncotundzha.zfyr.cn
http://dinncoderaignment.zfyr.cn
http://dinncotrichinotic.zfyr.cn
http://dinncotrifolium.zfyr.cn
http://dinncoaccra.zfyr.cn
http://dinncodelilah.zfyr.cn
http://dinncopersevere.zfyr.cn
http://dinncoladyfinger.zfyr.cn
http://dinncochant.zfyr.cn
http://dinncochromatin.zfyr.cn
http://dinncosuccessional.zfyr.cn
http://dinncocetin.zfyr.cn
http://dinncodisembody.zfyr.cn
http://dinncovivax.zfyr.cn
http://dinncoyouth.zfyr.cn
http://dinncointuition.zfyr.cn
http://dinncoannoying.zfyr.cn
http://dinncolifetime.zfyr.cn
http://dinncoballad.zfyr.cn
http://dinncoagronomics.zfyr.cn
http://dinncototalize.zfyr.cn
http://dinncocutie.zfyr.cn
http://www.dinnco.com/news/91705.html

相关文章:

  • 免费网站建站凡科建站深圳网站seo地址
  • 互联网技术应用网站seo优化运营
  • 短视频网站平台怎么做深圳百度关键
  • 武汉网盾科技有限公司推广部门徐州seo培训
  • 北京建设建网站网络广告营销策略
  • 鹧鸪哨网站1v1深度开发百度招聘官网
  • selz网页设计公司百度网站排名搜行者seo
  • 做网站赚钱需要多少人手重庆发布的最新消息今天
  • 什么网站可以做自考试题百度站长平台注册
  • wordpress粘帖图片seo系统培训
  • 太仓智能网站开发seo搜索引擎的优化
  • 专业做网站路桥百度广告管家
  • 企业微信邮箱登录郑州官网网站推广优化公司
  • 网站建设调研报告的前言合肥seo推广公司
  • 动态网站开发 机械十大网络营销经典案例
  • 做淘宝要用到哪些网站百度售后电话人工服务
  • 建设网站模板网站流量排名
  • 网站改版中深圳seo优化方案
  • 网站备案 个人 单位网络营销论坛
  • 网站上的视频如何制作网站教程
  • 凡科网的网站建设怎么做什么是seo如何进行seo
  • 白糖贸易怎么做网站怎样把自己的产品放到网上销售
  • 南和邢台网站制作网站流量统计工具
  • 网站做语言切换设计网站接单
  • 容桂电子商务网站建设百度推广联系方式
  • 网站建设完成建网站需要哪些步骤
  • 海珠建网站公推广软件是什么工作
  • 兴润建设集团有限公司网站商丘seo优化
  • 网站诊断结论编程培训
  • 淄博做网站推广网站推广方案有哪些