タイトル【小池邦人のプログラミング日記】2000/11/15<さよならBitMapまた会う日まで!>(プログラム)カテゴリーグラフィックス, 小池邦人のプログラミング日記
作成日2000/11/15 18:25:58作成者小池邦人

short makeBitMap( BitMap *map,Rect *rt,Handle *dhd )
{
short row;
long len,wh,wv;
Handle hd;

wh=rt->right-rt->left;
wv=rt->bottom-rt->top;
if( wh&7 )
row=(wh>>3)+1;
else
row=wh>>3;
row=longWord( row );
len=wv*row;
if( hd=NewHandleClear( len ) )
{
HLock( hd );
map->baseAddr=*hd;
map->rowBytes=row;
map->bounds=*rt;
*dhd=hd;
return( 0 );
}
return( 1 );
}

short longWord( short rowbyte )
{
if( rowbyte&3 )
rowbyte=((rowbyte>>2)+1)<<2;
return( rowbyte );
}

============================================================

short makeClickRegion( PicHandle pict,Point pt,RgnHandle *rgn )
{
PixMapHandle spix,dpix;
CGrafPtr off1,off2;
short ret=1;
long color;
GWorldPtr gptr;
RgnHandle rgn1;
Rect drt;
GDHandle ghd;
RGBColor rgb;

GetGWorld( &gptr,&ghd );
drt=(*pict)->picFrame;
OffsetRect( &drt,-drt.left,-drt.top );
if( ! NewGWorld( &off1,32,&drt,0L,0L,0 ) )
{
spix=GetGWorldPixMap( off1 );
LockPixels( spix );
if( ! NewGWorld( &off2,1,&drt,0L,0L,0 ) )
{
dpix=GetGWorldPixMap( off2 );
LockPixels( dpix );

SetGWorld( off1,0L );
DrawPicture( pict,&drt );
GetCPixel( pt.h,pt.v,&rgb );
color=Color2Index( &rgb );
SeedCFill( (BitMap *)*spix,(BitMap *)*dpix,&drt,&drt,pt.h,pt.v,NULL,color );
SetGWorld( gptr,ghd );
if( rgn1=NewRgn() )
{
if( ! ( ret=BitMapToRegion( rgn1,(BitMap *)*dpix ) ) )
*rgn=rgn1;
else
DisposeRgn( rgn1 );
}
DisposeGWorld( off2 );
}
DisposeGWorld( off1 );
}
SetGWorld( gptr,ghd );
return( ret );
}
関連リンク