releasedc(releasedc)_调用halcon函数安防好能详细点

电脑维修 2023-07-17 19:24www.caominkang.com电脑维修知识

releasedc调用halcon函数安防好能详细点?

从halcon到vc++

read_image(&image,”文件名”);//读入的为灰度图像

//获取图像指针注意输出变量的类型

charlpcstype[max_string];

hlongpointer,idth,height;

get_image_pointer1(image,&pointer,lpcstype,&idth,&height);

//halcon与vc++中的图像之间存在着上下翻转

bytelpbyte;

byteimageg;

intbyteidth;

byteidth=((long)idth3+3)/44;

imageg=null;

imageg=nebyte[byteidth(long)height];

lpbyte=(byte)pointer;//注意结合图像像素存储的类型进行定义

inti,j;

for(j=(long)height-1;j>=0;j–)

{//(注意tuple中图像数据的存放和vc中的差别)

for(i=0;i

{

(imageg+jbyteidth+i3+0)=lpbyte;

(imageg+jbyteidth+i3+1)=lpbyte;

(imageg+jbyteidth+i3+2)=lpbyte;

lpbyte++;

}

}

bitmapinforotatebmpinfo;

bytebitbuffer;

bitbuffer=null;

bitbuffer=nebyte[sizeof(bitmapinfo)];

rotatebmpinfo=(bitmapinfo)bitbuffer;

rotatebmpinfo->bmiheader.bisize=sizeof(bitmapinfoheader);

rotatebmpinfo->bmiheader.biheight=height;

rotatebmpinfo->bmiheader.biidth=idth;

rotatebmpinfo->bmiheader.biplanes=1;

rotatebmpinfo->bmiheader.bibitcount=24;

rotatebmpinfo->bmiheader.bipression=bi_rgb;

rotatebmpinfo->bmiheader.bisizeimage=heightbyteidth;

rotatebmpinfo->bmiheader.bixpelspermeter=0;

rotatebmpinfo->bmiheader.biypelspermeter=0;

rotatebmpinfo->bmiheader.biclrused=0;

rotatebmpinfo->bmiheader.biclrimportant=0;

cndm_pnd;

m_pnd=afxgetapp()->getmainnd();

cdcpdc=m_pnd->getdc();

::stretchdibits(

pdc->getsafehdc(),

idth+10,

height+10,

idth,//显示窗口宽度

height,//显示窗口高度

0,

0,

idth,//图像宽度

height,//图像高度

imageg,

rotatebmpinfo,

dib_rgb_colors,

sropy);

m_pnd->releasedc(pdc);

delete[]imageg;

delete[]bitbuffer;

2.从vc++到halcon

unsignedcharpointer;

intidth,height;

pointer=neunsignedchar[idthheight];

inti,j;

for(i=0;i

Copyright © 2016-2025 www.caominkang.com 曹敏电脑维修网 版权所有 Power by