Euresys eVision 加载和保存图像

来源:互联网 发布:ubuntu安装gnome2 编辑:程序博客网 时间:2024/05/20 11:24

Euresys eVision  EImageBW8类的Load方法加载上来的图像像素值是按照列存储的,而自己创建EImgBW8类的Save方法保存图像时要求像素值是按照行顺序存储的。正确的加载和保存图像的方法为:


#include "stdafx.h"#include "Easy.h"void main(int argc, char* argv[]){ EImageBW8 Img1; EImageBW8 Img2; Img2.Load("D:\\87.bmp"); unsigned char* temppix = (unsigned char*)malloc(Img2.GetHeight()*Img2.GetWidth()); Img1.SetSize(Img2.GetWidth(), Img2.GetHeight()); for (int i = 0; i < Img2.GetHeight(); i++) {   for (int j = 0; j < Img2.GetWidth(); j++)   {      temppix[i * Img2.GetWidth() + j] = Img2.GetImagePtr(j, i)->m_un8Value;   }}   Img1.SetImagePtr(Img2.GetWidth(), Img2.GetHeight(), temppix);   Img1.Save("D:\\Pix3.bmp");   free(temppix);   return;}




0 0