從halcon到vc++
read_image(&image,"檔名");//讀入的為灰度影象
//獲取影象指標,注意輸出變數的型別
charlpcstype[max_string];
hlongpointer,width,height;
get_image_pointer1(image,&pointer,lpcstype,&width,&height);
//halcon與vc++中的影象之間,存在著上下翻轉
byte*lpbyte;
byte*imageg;
intbytewidth;
bytewidth=((long)width*3+3)/4*4;
imageg=null;
imageg=newbyte[bytewidth*(long)height];
lpbyte=(byte*)pointer;//注意結合影象畫素儲存的型別進行定義
inti,j;
for(j=(long)height-1;j>=0;j--)
{//(注意tuple中影象資料的存放和vc中的差別)
for(i=0;i
{
*(imageg+j*bytewidth+i*3+0)=*lpbyte;
*(imageg+j*bytewidth+i*3+1)=*lpbyte;
*(imageg+j*bytewidth+i*3+2)=*lpbyte;
lpbyte++;
}
bitmapinfo*rotatebmpinfo;
byte*bitbuffer;
bitbuffer=null;
bitbuffer=newbyte[sizeof(bitmapinfo)];
rotatebmpinfo=(bitmapinfo*)bitbuffer;
rotatebmpinfo->bmiheader.bisize=sizeof(bitmapinfoheader);
rotatebmpinfo->bmiheader.biheight=height;
rotatebmpinfo->bmiheader.biwidth=width;
rotatebmpinfo->bmiheader.biplanes=1;
rotatebmpinfo->bmiheader.bibitcount=24;
rotatebmpinfo->bmiheader.bicompression=bi_rgb;
rotatebmpinfo->bmiheader.bisizeimage=height*bytewidth;
rotatebmpinfo->bmiheader.bixpelspermeter=0;
rotatebmpinfo->bmiheader.biypelspermeter=0;
rotatebmpinfo->bmiheader.biclrused=0;
rotatebmpinfo->bmiheader.biclrimportant=0;
cwnd*m_pwnd;
m_pwnd=afxgetapp()->getmainwnd();
cdc*pdc=m_pwnd->getdc();
::stretchdibits(
pdc->getsafehdc(),
width+10,
height+10,
width,//顯示視窗寬度
height,//顯示視窗高度
0,
width,//影象寬度
height,//影象高度
imageg,
rotatebmpinfo,
dib_rgb_colors,
srccopy);
m_pwnd->releasedc(pdc);
delete[]imageg;
delete[]bitbuffer;
2.從vc++到halcon
unsignedchar*pointer;
intwidth,height;
pointer=newunsignedchar[width*height];
從halcon到vc++
read_image(&image,"檔名");//讀入的為灰度影象
//獲取影象指標,注意輸出變數的型別
charlpcstype[max_string];
hlongpointer,width,height;
get_image_pointer1(image,&pointer,lpcstype,&width,&height);
//halcon與vc++中的影象之間,存在著上下翻轉
byte*lpbyte;
byte*imageg;
intbytewidth;
bytewidth=((long)width*3+3)/4*4;
imageg=null;
imageg=newbyte[bytewidth*(long)height];
lpbyte=(byte*)pointer;//注意結合影象畫素儲存的型別進行定義
inti,j;
for(j=(long)height-1;j>=0;j--)
{//(注意tuple中影象資料的存放和vc中的差別)
for(i=0;i
{
*(imageg+j*bytewidth+i*3+0)=*lpbyte;
*(imageg+j*bytewidth+i*3+1)=*lpbyte;
*(imageg+j*bytewidth+i*3+2)=*lpbyte;
lpbyte++;
}
}
bitmapinfo*rotatebmpinfo;
byte*bitbuffer;
bitbuffer=null;
bitbuffer=newbyte[sizeof(bitmapinfo)];
rotatebmpinfo=(bitmapinfo*)bitbuffer;
rotatebmpinfo->bmiheader.bisize=sizeof(bitmapinfoheader);
rotatebmpinfo->bmiheader.biheight=height;
rotatebmpinfo->bmiheader.biwidth=width;
rotatebmpinfo->bmiheader.biplanes=1;
rotatebmpinfo->bmiheader.bibitcount=24;
rotatebmpinfo->bmiheader.bicompression=bi_rgb;
rotatebmpinfo->bmiheader.bisizeimage=height*bytewidth;
rotatebmpinfo->bmiheader.bixpelspermeter=0;
rotatebmpinfo->bmiheader.biypelspermeter=0;
rotatebmpinfo->bmiheader.biclrused=0;
rotatebmpinfo->bmiheader.biclrimportant=0;
cwnd*m_pwnd;
m_pwnd=afxgetapp()->getmainwnd();
cdc*pdc=m_pwnd->getdc();
::stretchdibits(
pdc->getsafehdc(),
width+10,
height+10,
width,//顯示視窗寬度
height,//顯示視窗高度
0,
0,
width,//影象寬度
height,//影象高度
imageg,
rotatebmpinfo,
dib_rgb_colors,
srccopy);
m_pwnd->releasedc(pdc);
delete[]imageg;
delete[]bitbuffer;
2.從vc++到halcon
unsignedchar*pointer;
intwidth,height;
pointer=newunsignedchar[width*height];
inti,j;
for(i=0;i