首页 > 编程知识 正文

putimage没显示图片,section生成jpg图片是空白的

时间:2023-05-06 09:18:02 阅读:47812 作者:1100

构建QImage时

方法1 :

* qimage :3360 qimage (构造函数,int width,int height,格式格式,qimagecleanupfunction cleanupfunction=q _

constructsanimagewiththegivenwidth,height and format,thatusesanexistingread-onlymemorybuffer,data.thewidthandheightmustion data must be 32-bit aligned,andeachscanlineofdataintheimagemustalsobe 32-bibitalsobe

thebuffermustremainvalidthroughoutthelifeoftheqimageandallcopiesthavenotbeenmodifiedorotherwisedetachedfromtheoriginalbuffe hebufferatdestruction.youcanprovideafunctionpointercleanupfunctionalongwithanextrapointercleanupinnnition

if格式is an indexed color格式,theimagecolortableisinitiallyemptyandmustbesufficientlyexpandedwithsetcolorcount (

unlikethesimilarqimageconstructorthattakesanon-constdatabuffer, thisversionwillneveralterthecontentsofthebuffer.forexamplication calling qimage : bits (willreturnadeeeepcopyoftheimage ratherthanthebufferpassedtotheconstructor.thisallowsfortheefficiencyofconstructingaqimagefromrawdata,withoutthepossibility

创建指定宽度、高度和格式的图像。 该图像使用现有的只读内存缓冲区数据。 宽度和高度必须以像素为单位指定,数据必须以32位对齐,图像中数据的每条扫描线也必须以32位对齐。

缓冲区在整个QImage生命周期内都是有效的,任何未更改或与原始缓冲区断开的拷贝都必须有效。 图像不会删除已销毁的缓冲区。 可以指定函数指针cleanupFunction和在销毁最后一个副本时调用的其他指针cleanupInfo。

如果格式为索引颜色格式,则图像颜色表最初为空,因此在使用图像之前必须使用setColorCount (或setColorTable )进行充分扩展。

与使用非常大数据缓冲区的QImage构造函数不同,此版本不更改缓冲区的内容。 例如,调用QImage : bits ()将返回图像的深度副本,而不是传递到构造函数的缓冲区。 这样,可以根据原始数据构建QImage效率,而无需更改原始数据。

方法2 :

* qimage :3360 qimage (uchar data,int width,int height,int bytesPerLine,格式,qimagecleanupfunctioncleanupfirene

constructsanimagewiththegivenwidth,height and format,that uses an existing memory buffer,data.thewidthandheightmustbespespecifiefer

thebuffermustremainvalidthroughoutthelifeoftheqimageandallcopiesthavenotbeenmodifiedorotherwisedetachedfromtheoriginalbuffe hebufferatdestruction.youcanprovideafunctionpointercleanupfunctionalongwithanextrapointercleanupinnnition

if格式is an indexed color格式,theimagecolortableisinitiallyemptyandmustbesufficientlyexpandedwithsetcolorcount (

使用现有内存缓冲区数据创建指定宽度、高度和格式的图像。 宽度和高度必须以像素为单位指定。 bytesPerLine指定每行的字节数(跨度)。

缓冲区在整个QImage生命周期内都是有效的,任何未更改或与原始缓冲区断开的拷贝都必须有效。 图像不会删除已销毁的缓冲区。 可以指定函数指针cleanupFunction和在销毁最后一个副本时调用的其他指针cleanupInfo。

如果格式为索引颜色格式,则图像颜色表最初为空,因此在使用图像之前必须使用setColorCount (或setColorTable )进行充分扩展。

首先使用方法生成图像,但生成的qimage由于方法QImage:save方法保存的图像损坏而无法打开

之后,我们使用方法生成了图像。 也就是说,我们确定了bytesperline(1 (每行的字节数)。 这样生成的qimage将正常并成功保存。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。