Discussion:
キャプチャした画像にクロスヘアを描いて画面に表示したい
(too old to reply)
Imo
2009-04-09 04:30:40 UTC
Permalink
$B%-%c%W%A%c$7$?2hA|(B(bitmap)$B$K%/%m%9%X%"$rIA$/>l9g!"(B
$B2hA|(B(bitmap)$B$r(BStrechBlt$B$GI=<($7$?8e$K(BMoveTo-LineTo$B$G%/%m%9%X%"$rIA$/$H!!2hLL$,$A$i$D$$$F$7$^$$$^$9!#(B

bitmap$B$r=L>.I=<($9$k4X78$G85$N(Bbitmap$B$K%/%m%9%X%"$rKd$a9~$`>l9g!"=L>.N($r7W;;$7$FB@$$@~$rKd$a9~$^$J$1$l$P$J$j$^$;$s!#(B

$B$=$3$G!"(B
$B0lC6!"%a%b%j!<>e$K2hLL$N(BDC$B$HF1$8J*$r:***@.$7!"!!$=$3$K=L>.I=<($7$?(Bbitmap$B$rKd$a9~$_!!%/%m%9%X%"$rIA$$$F!!$=$N(BDC$B$r2hLL(BDC$B$K(BBitBlt$B$G%3%T!<$9$l$P!%!%!%!%$H;W$C$?$N$G$9$,!!I=<(=PMh$^$;$s!#(B

$B2?$+:,K\E*$K4V0c$C$F$$$k$N$G$7$g$&$+!)(B



MLOCAL int Xbitmap_disp( HDC hDC, BITMAPINFO *bi, char *bd, RECT *rc )
{
HBITMAP hBitmap;
HDC hdcBitmap;
HDC hdcBitmap2;
HDC hDCx;

bmp_width = (bi->bmiHeader).biWidth;
bmp_hight = (bi->bmiHeader).biHeight;
hBitmap = CreateDIBitmap( hDC
, (BITMAPINFOHEADER*) bi
, CBM_INIT
, (SBYT*) bd
, (BITMAPINFO*) bi
, DIB_RGB_COLORS);
hdcBitmap = CreateCompatibleDC( hDC ); // $B2hLL$HF1$8(BDC$B$N:***@.!J#1!K(B



hdcBitmap2 = CreateCompatibleDC( hDC ); // $B2hLL$HF1$8(BDC$B$N:***@.!J#2!K(B



SelectObject( hdcBitmap , hBitmap);
StretchBlt $B!!(B( hdcBitmap2 , rc->left, rc->top, rc->right -rc->left,
rc->bottom - rc->top
$B!!!!!!(B, hdcBitmap, 0, 0, bmp_width, bmp_hight,SRCCOPY );
// $B=L>.E=$jIU$1(B
DeleteObject( hdcBitmap );
DeleteObject( hBitmap );
{
int x1, x2, xm;
int y1, y2, ym;
HPEN hPen;
$B!!!!!!(BhPen = CreatePen( PS_SOLID, 0, RGB( 0x00, 0xFF, 0x00 ) );
SelectObject( hdcBitmap2 , hPen );
y1 = rc->top ;
x1 = rc->left ;
y2 = rc->bottom;
x2 = rc->right ;
xm = ( x1 + x2 ) / 2;
ym = ( y1 + y2 ) / 2;
MoveToEx( hdcBitmap2 , x1, ym, NULL ); // $B%/%m%9%X%"(B
LineTo ( hdcBitmap2 , x2, ym );
MoveToEx( hdcBitmap2 , xm, y1, NULL );
LineTo ( hdcBitmap2 , xm, y2 );
DeleteObject( hPen );
}

// $B2hLL(BDC$B$X$N%3%T!<!!(B///
BitBlt ( hDC, rc->left, rc->top, bmp_width,
bmp_hight,hdcBitmap2, rc->left, rc->top, SRCCOPY );
DeleteObject( hdcBitmap2);
}
UETA, Shin-ichi
2009-04-09 05:30:37 UTC
Permalink
$B$3$s$K$A$O!"?"ED$G$9!#(B
$B$=$3$K=L>.I=<($7$?(Bbitmap$B$rKd$a9~$_!!%/%m%9%X%"$rIA$$$F(B
$B$=$N(BDC$B$r2hLL(BDC$B$K(BBitBlt$B$G%3%T!<$9$l$P!%!%!%!%(B
$B$^$!!"$=$l$,>oEe<jCJ$G$9!#(B
SelectObject( hdcBitmap , hBitmap);
StretchBlt $B!!(B( hdcBitmap2 , rc->left, rc->top, rc->right -rc->left, rc->bottom - rc->top
$B!!!!!!(B, hdcBitmap, 0, 0, bmp_width, bmp_hight,SRCCOPY );
$B$3$N%3!<%I$r8+$k$+$.$j!"(BhdcBitmap2 $B$K%S%C%H%^%C%W$r%"%?%C%A$7$F(B
$B$$$J$$$h$&$G$9$1$I(B...?

$B%3%T!<85$H%3%T!<@h!"$=$l$>$l$KE,@Z$J%S%C%H%^%C%W$r%"%?%C%A$7$F(B
$B$*$+$J$$$H4|BT$9$k$h$&$J7k2L$K$O$J$j$^$;$s!#(B
Windows$B$,%3%T!<@h$N%S%C%H%^%C%W$r<+F0E*$K:n$C$F$/$l$k$o$1$G$O(B
$B$"$j$^$;$s$+$i(B...$B!#(B
DeleteObject( hdcBitmap );
DeleteObject( hBitmap );
hdcBitmap $B$d(B hBitmap $B$rGK4~$9$kA0$K!"85$N%S%C%H%^%C%W$rI|85$7$F(B
$B$*$$$?J}$,$h$m$7$$$+$H;W$$$^$9!#(B
CreateCompatibleDC$B;~$K%G%U%)%k%H$N%S%C%H%^%C%W!J(B1$B!_(B1$B$N%b%N%/%m(B
$B%S%C%H%^%C%W!K$,3d$jEv$F$i$l$F$$$^$9!#(B
$B0lHL$K$O!"(BSelectObject$B;~$K0JA0$N%O%s%I%k$rJ]B8$7$F$*$-!"IA2h(B
$B$,=*$o$C$?8e$G85$N%O%s%I%k$r(BDC$B$KLa$7$^$9!#(B

# hdcBitmap2 $B$K3d$jEv$F$k%S%C%H%^%C%W$K$D$$$F$bF1MM$G$9!#(B
# $B$^$?!"%Z%s$b(BGDI$B%*%V%8%'%/%H$J$N$G!"F1$8$h$&$K%G%U%)%k%H$KLa$9(B
# $BI,MW$,$"$j$^$9!#(B
--
$B?"ED%7%9%F%`@_7W;vL3=j(B
Ueta System Design Studio
http://www.usdesign.jp/
$B?"ED??0l(B
mailto:***@usdesign.jp
Imo
2009-04-09 10:01:18 UTC
Permalink
$BM-$jFq$&$4$6$$$^$7$?!#!!!!B?>/!)F0$-;O$a$^$7$?!#(B

$BBgJQ?=$7Lu$J$$$N$G$9$,!"(B $BEvJ}!!F,$,8G$$<T$GM}2r$G$-$F$$$J$$$N$G$9$,(B
$B$3$N%3!<%I$r8+$k$+$.$j!"(BhdcBitmap2 $B$K%S%C%H%^%C%W$r%"%?%C%A$7$F$$$J$$$h$&$G$9$1$I(B...?
$B$H$O!"6qBNE*$K$I$N$h$&$J$3$H$r$7$F$*$1$P$h$$$N$G$7$g$&$+!)(B
Win32$B%l%Y%k$N%=%U%H$r=q$$$F$$$k$N$G$9$,<h$j$"$($:!"%O%s%I%k$NI|5lEy$O9T$C$F$$$^$;$s$,!!0J2<$N$h$&$K$7$F$_$^$7$?!#(B
$B$h$m$7$/$465<x4j$$$^$9!#(B


MLOCAL int Xbitmap_disp( HDC hDC, BITMAPINFO *bi, char *bd, RECT *rc )
{
HBITMAP hBitmap;
HBITMAP hBitmap2;
HDC hdcBitmap;
HDC hdcBitmap2;
HPEN hPen;

bmp_width = (bi->bmiHeader).biWidth;
bmp_hight = (bi->bmiHeader).biHeight;
hBitmap = CreateDIBitmap( hDC
, (BITMAPINFOHEADER*) bi
, CBM_INIT
, (SBYT*) bd
, (BITMAPINFO*) bi
, DIB_RGB_COLORS);
hBitmap2 = CreateDIBitmap( hDC
, (BITMAPINFOHEADER*) bi
, CBM_INIT
, (SBYT*) bd
, (BITMAPINFO*) bi
, DIB_RGB_COLORS);
hdcBitmap = CreateCompatibleDC( hDC );
hdcBitmap2 = CreateCompatibleDC( hDC );
SelectObject( hdcBitmap , hBitmap);
SelectObject( hdcBitmap2, hBitmap2);
StretchBlt ( hdcBitmap2, 0, 0, rc->right - rc->left, rc->bottom -
rc->top
, hdcBitmap , 0, 0, bmp_width, bmp_hight, SRCCOPY ); //
$B=L>.(B
{
int x1, x2, xm;
int y1, y2, ym;
hPen = CreatePen( PS_SOLID, 0, RGB( 0x00, 0xFF, 0x00 ) );
SelectObject( hdcBitmap2, hPen );
y1 = rc->top ;
x1 = rc->left ;
y2 = rc->bottom;
x2 = rc->right ;
y1 = 0;
x1 = 0;
y2 = rc->bottom - rc->top ;
x2 = rc->right - rc->left ;
xm = ( x1 + x2 ) / 2;
ym = ( y1 + y2 ) / 2;
MoveToEx( hdcBitmap2, x1, ym, NULL ); // $B%/%m%9%X%"(B
LineTo ( hdcBitmap2, x2, ym );
MoveToEx( hdcBitmap2, xm, y1, NULL );
LineTo ( hdcBitmap2, xm, y2 );
}

BitBlt ( hDC, rc->left, rc->top, bmp_width, bmp_hight
, hdcBitmap2, 0, 0, SRCCOPY ); // $B<B2hLL$X$N%3%T!<(B
DeleteObject( hPen );
DeleteObject( hdcBitmap2);
DeleteObject( hdcBitmap );
DeleteObject( hBitmap2 );
DeleteObject( hBitmap );
return ( 0 );
}
UETA, Shin-ichi
2009-04-09 11:08:09 UTC
Permalink
$B$I$&$b!"?"ED$G$9!#(B
$BJL$N%"%W%m!<%A$H$7$F$O!"$?$H$($P!"(BhBitmap $B$r$=$N$^$^%-%c%s%P%9(B
$B$H$7$F;H$$!"%&%#%s%I%&$K%3%T!<$9$k$H$-$K=L>.$9$kJ}K!$b$"$m$&$+$H(B
$B;W$$$^$9!J(BhBitmap2$B$d(BhdcBitmap2$B$OITMW$K$J$j$^$9!K!#(B
$B$1$l$P$J$j$^$;$s!#(B
$BEvJ}!"%0%i%U%#%C%/%97O$OAB$$$N$G$"$^$j?<$/9M$($^$;$s$G$7$?$,!J6l>P!K!"(B
$B%/%m%9%X%"$C$F!"%^%&%9$NF0$-$KDI=>$9$k>H=`$N$3$H$G$9$+(B?
$B$@$H$9$k$H%/%m%9%X%"$O=L>.$7$?8e$N%S%C%H%^%C%W$KIA2h$7$?J}$,$h$5$=$&(B
$B$G$9$M!#(B
--
$B?"ED%7%9%F%`@_7W;vL3=j(B
Ueta System Design Studio
http://www.usdesign.jp/
$B?"ED??0l(B
mailto:***@usdesign.jp
UETA, Shin-ichi
2009-04-09 10:58:49 UTC
Permalink
$B$I$&$b!"?"ED$G$9!#(B
$B6qBNE*$K$I$N$h$&$J$3$H$r$7$F$*$1$P$h$$$N$G$7$g$&$+!)(B
$B%3%T!<85$H$J$k%S%C%H%^%C%W$r(B hdcBitmap $B$K%"%?%C%A$7$F$$$k$N$H(B
$BF1$8$h$&$K!"=L>.$7$?%$%a!<%8$rIA2h$9$k$N$K==J,$JBg$-$5$r;}$D(B
$B%S%C%H%^%C%W$r(BhdcBitmap2$B$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