我从一个设备中,读取到了图像的数据,是一些十六进制数字,如何根据这些图像数据来生成一个图像文件,请高手帮忙!!!
这是我自己写的代码,没有实现上述功能;
/***************************************************************************************/
void FileOperation::save_image(QString image_name,char *image_content)
{
QImage fingprinter_image=QImage(image_content);//image_content 接受到的是一个数组中的数据
fingprinter_image.save("./fingprinter_image/"+image_name,"PNG");
}
/*************************************************************************************/
这是我最新的代码,能够生成图片,但是显示出来的东西不是我想要的,高手看看有什么问题吗?
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FileOperation::save_image(QString image_name,uchar *image_content)
{
QBitmap bitmap=QBitmap(280,280,image_content,TRUE);
QImage fingprinter_image=bitmap.convertToImage();
fingprinter_image.save("./fingprinter_image/"+image_name,"BMP");
// printf("image_name is %s",image_name);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
下面是我参考的资料,我用的是2.3.7和2.3.2的版本
///////////////////////////////////////////////////////////////
The QBitmap class provides monochrome (1-bit depth) pixmaps. More...
#include <qbitmap.h>
Inherits QPixmap.
//////////////////////////////////////////////////////
QBitmap::QBitmap ( int w, int h, const uchar * bits, bool isXbitmap = FALSE )
Constructs a bitmap with width w and height h and sets the contents to bits.
The isXbitmap flag should be TRUE if bits was generated by the X11 bitmap program. The X bitmap bit order is little endian. The QImage documentation discusses bit order of monochrome images.
Example (creates an arrow bitmap):
uchar arrow_bits[] = { 0x3f, 0x1f, 0x0f, 0x1f, 0x3b, 0x71, 0xe0, 0xc0 };
QBitmap bm( 8, 8, arrow_bits, TRUE );
///////////////////////////////////////////////////////////////////////////////////////////////////qpixmap类中的方法/////////////////////////
QImage QPixmap::convertToImage () const
Converts the pixmap to a QImage. Returns a null image if it fails.
If the pixmap has 1-bit depth, the returned image will also be 1 bit deep. If the pixmap has 2- to 8-bit depth, the returned image has 8-bit depth. If the pixmap has greater than 8-bit depth, the returned image has 32-bit depth.
Note that for the moment, alpha masks on monochrome images are ignored.
See also convertFromImage().
///////////////////////////////////////////////qimage类中的方法///////////////////////////////////////////////////////////////////////
bool QImage::save ( const QString & fileName, const char * format, int quality = -1 ) const
Saves the image to the file fileName, using the image file format format and a quality factor of quality. quality must be in the range 0..100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 (the default) to use the default settings.
Returns TRUE if the image was successfully saved; otherwise returns FALSE.
See also load(), loadFromData(), imageFormat(), QPixmap::save() and QImageIO.
[ 此帖被jxq19881013在2009-05-28 10:20重新编辑 ]