Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- combo();
- function combo()
- {
- $filename='dtbykick';
- $image[ 'rgb' ] = imagecreatefrombmp( $_SERVER['DOCUMENT_ROOT']. '/Roe XAMPP Builder/tiles src data/rgb/'.$filename.'.bmp' );
- $image[ 'mask' ] = imagecreatefrombmp( $_SERVER['DOCUMENT_ROOT']. '/Roe XAMPP Builder/tiles src data/mask/'.$filename.'.bmp' );
- //imagepng( $image['combo'],'./'.$filename.'-combo.png' );
- $image [ 'combo' ] = imagecreatetruecolor( imagesx( $image[ 'rgb' ] ), imagesy( $image[ 'rgb' ] ) );
- $width = imagesx( $image[ 'combo' ] );
- $height = imagesy( $image[ 'combo' ] );
- //loop through width and height of source image
- $row=0;
- $col=0;
- while( $row < $height )
- {
- while( $col < $width )
- {
- //get color in image $image[ 'mask' ] at pixel ($col,$row)
- $pix[ 'mask' ] = imagecolorat( $image[ 'mask' ], $col, $row );
- //get color in image $image[ 'rgb' ] at pixel ($col,$row)
- $pix[ 'rgb' ] = imagecolorat( $image[ 'rgb' ], $col, $row );
- //if pixel in $image['mask'] at ($cow,$row) is white:
- if ( ( $pix[ 'rgb' ] & 0xFFFFFF ) === 0xFFFFFF )
- {
- //set pixel in $image['combo'] at ($cow,$row) as fully transparent
- imagesetpixel( $image[ 'combo' ], $col, $row, 0x7000000 );
- }
- //else
- else
- {
- //set pixel in $image['combo'] at ($cow,$row) as pixel color in $image['rgb'] at ($cow,$row) with full opacity
- imagesetpixel( $image[ 'combo' ], $col, $row, 0xF000000 | $pix[ 'rgb' ] );
- }
- if( $col === $width - 1 )
- {
- break;
- }
- $col++;
- }
- if( $row === $height - 1 )
- {
- break;
- }
- $row++;
- }
- //save resulting image as new file
- imagepng( $image[ 'combo' ], $_SERVER['DOCUMENT_ROOT']. '/Roe XAMPP Builder/tiles out data/combo/'. $filename. '.png' );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement