Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $filename='dtbykick';
- combo($filename);
- echo '<html><head><title>'. $filename. '</title></head><body style="background-color:springgreen;"><h3>'. htmlentities( $filename ). '</h3><img src="./tiles src data/rgb/'. $filename. '.bmp"><img src="./tiles src data/mask/'. $filename. '.bmp"><img src="./tiles out data/combo/'. $filename. '.png"></body></html>';
- function combo($filename='dtbykick')
- {
- //$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;
- while( $row < $height )
- {
- $col=0;
- 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[ 'mask' ] & 0xFFFFFF ) === 0xFFFFFF )
- {
- //set pixel based on Mask layer's ($col, $row) as fully transparent
- $pix[ 'combo' ] = alphaColor("FFFFFF",127);
- }
- //else
- else
- {
- //set pixel based on RGB layer's ($col, $row) with full opacity
- $pix[ 'combo' ] = $pix[ 'rgb' ];
- }
- //assign pixel data to $image['combo'] at ($col , $row)
- imagesetpixel( $image[ 'combo' ], $col, $row, $pix[ 'combo' ] );
- 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' );
- }
- function alphaColor($hexColor,$alpha)
- {
- return bindec(decbin($alpha).decbin(hexdec($hexColor)));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement