b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

如何将wxImage存储到中,使用C ++?

电脑杂谈  发布时间:2019-11-09 22:03:46  来源:网络整理

mysql保存中文乱码_mysql 保存富文本格式_c++ mysql保存图片

百度翻译此文有道翻译此文

问 题

I have some wxImages and I would like to store them into a BLOB (Binary Large OBject) field in a MySQL database.

There are no methods in nor for obtaining the binary data as an array of unsigned char so I can load into the database.

My current workaround is to write the image to a temporary file, then load the BLOB field directly from the file.

Is there a more efficient method to load and store a wxImage object into a MySQL BLOB field?

I am using MySql C++ connector 1.05, MS Visual Studio 2008, wxWidgets and C++.

解决方案

wxWidgets doesn't provide any API to the data from wxBitmap (because it's platform-dependent) but wxImage uses a well-defined (and very simple) format which you can access using its GetData() method as mentioned above. Just notice that you may need to use GetAlpha() as well if your images have alpha channel.

However this is not how I'd do it because the data will be huge if you do it like this. While compressing it, as also suggested above, is possible, why bother doing it manually when wxImage already supports writing image in any of the standard image formats. Just create a wxMemoryOutputStream and pass it to SaveFile(). Then simply access the stream buffer directly using GetOutputStreamBuffer()->GetBufferStart() and related functions.

mysql保存中文乱码_mysql 保存富文本格式_c++ mysql保存图片

本文地址:IT屋 How to store wxImage into database, using C++?

问 题

我有一些wxImages,我想将他们存储到 BLOB (二进制大对象)字段

或获得二进制数据成为 unsigned char 所以我可以加载到。

我现在的解决办法是将图像读取一个临时文件,然后

有没有更有效的方式来读取和内存wxImage对象到MySQL BLOB字段?

我使用的是MySql C ++连接器1.05,MS Visual Studio 2008, wxWidgets 和

解决方案

wxWidgets不提供任何API来自 wxBitmap (因为它是系统相关的),但是 wxImage 使用一个定义明确(非常简洁)的格式,你可以使用 GetData )方法。只要切记,如果你的截图有alpha通道,你也许还必须使用 GetAlpha()。

是不是我会这样做,因为一旦你这样做,数据将很大。虽然压缩它,如上所述,也是也许的,为什么要在 wxImage 已经支持以任何标准图像格式编写图像时自动进行。只需创建一个 wxMemoryOutputStream 并将其释放给 SaveFile()。然后直接使用 GetOutputStreamBuffer() - > GetBufferStart()和相关变量访问流缓冲区。

c++ mysql保存图片_mysql 保存富文本格式_mysql保存中文乱码

本文地址:IT屋 如何将wxImage存储到中,使用C ++?

官方微信

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ”c++ mysql保存图片,选择关注

与百万开发者在一起

官方交流群:IT屋-技术交流群③

Google Facebook Youtube 科学上网》戳这里《

百度翻译此文有道翻译此文

问 题

我有一些wxImages,我想将他们存储到 BLOB (二进制大对象)字段。

mysql 保存富文本格式_mysql保存中文乱码_c++ mysql保存图片

或获得二进制数据成为 unsigned char 所以我可以加载到。

我现在的解决办法是将图像读取一个临时文件,然后

有没有更有效的方式来读取和内存wxImage对象到MySQL BLOB字段?

我使用的是MySql C ++连接器1.05,MS Visual Studio 2008, wxWidgets 和

解决方案

wxWidgets不提供任何API来自 wxBitmap (因为它是系统相关的),但是 wxImage 使用一个定义明确(非常简洁)的格式,你可以使用 GetData )方法。只要切记c++ mysql保存图片,如果你的截图有alpha通道,你也许还必须使用 GetAlpha()。

是不是我会这样做,因为一旦你这样做,数据将很大。虽然压缩它,如上所述,也是也许的,为什么要在 wxImage 已经支持以任何标准图像格式编写图像时自动进行。只需创建一个 wxMemoryOutputStream 并将其释放给 SaveFile()。然后直接使用 GetOutputStreamBuffer() - > GetBufferStart()和相关变量访问流缓冲区。

本文地址:IT屋 如何将wxImage存储到中,使用C ++?

问 题

I have some wxImages and I would like to store them into a BLOB (Binary Large OBject) field in a MySQL database.

mysql保存中文乱码_c++ mysql保存图片_mysql 保存富文本格式

There are no methods in nor for obtaining the binary data as an array of unsigned char so I can load into the database.

My current workaround is to write the image to a temporary file, then load the BLOB field directly from the file.

Is there a more efficient method to load and store a wxImage object into a MySQL BLOB field?

I am using MySql C++ connector 1.05, MS Visual Studio 2008, wxWidgets and C++.

解决方案

wxWidgets doesn't provide any API to the data from wxBitmap (because it's platform-dependent) but wxImage uses a well-defined (and very simple) format which you can access using its GetData() method as mentioned above. Just notice that you may need to use GetAlpha() as well if your images have alpha channel.

However this is not how I'd do it because the data will be huge if you do it like this. While compressing it, as also suggested above, is possible, why bother doing it manually when wxImage already supports writing image in any of the standard image formats. Just create a wxMemoryOutputStream and pass it to SaveFile(). Then simply access the stream buffer directly using GetOutputStreamBuffer()->GetBufferStart() and related functions.

本文地址:IT屋 How to store wxImage into database, using C++?

官方微信

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ” ,选择关注与百万开发者在一起


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-129448-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...