Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function adhere_tiles( &$image = array() )
- {
- $nen = nen_ini();
- $result = '';
- if( $image[ 'rgb' ] !== false )
- {
- $image [ 'combo' ] = imagecreatefrombmp( $nen[ 'root' ]. 'tiles src data/rgb/'. $image[ 'filename' ]. '.bmp' );
- }
- elseif( $image[ 'mask' ] !== false )
- {
- $image [ 'combo' ] = imagecreatefrombmp( $nen[ 'root' ]. 'tiles src data/mask/'. $image[ 'filename' ]. '.bmp' );
- }
- else
- {
- $image [ 'combo' ] = false;
- return;
- }
- //adhere rgb/mask tiles into single layer png
- if( $image[ 'rgb' ] !== false )
- {
- $width[ 'rgb' ] = imagesx( $image[ 'rgb' ] );
- $height[ 'rgb' ] = imagesy( $image[ 'rgb' ] );
- }
- else
- {
- $width[ 'rgb' ] = 0;
- $height[ 'rgb' ] = 0;
- }
- if( $image[ 'mask' ] !== false )
- {
- $width[ 'mask' ] = imagesx( $image[ 'mask' ] );
- $height[ 'mask' ] = imagesy( $image[ 'mask' ] );
- }
- else
- {
- $width[ 'mask' ] = 0;
- $height[ 'mask' ] = 0;
- }
- if( $image[ 'combo' ] !== false )
- {
- $width[ 'combo' ] = imagesx( $image[ 'combo' ] );
- $height[ 'combo' ] = imagesy( $image[ 'combo' ] );
- }
- else
- {
- $width[ 'combo' ] = 0;
- $height[ 'combo' ] = 0;
- }
- if( $image[ 'combo' ] === false )
- {
- return;
- }
- $result.= '<img src="./tiles out data/combo/'.$image[ 'filename' ]. '.png">';
- //imagecolortransparent( $image[ 'combo' ], 0);
- /*
- $fg = imagecolorexactalpha(
- $image['mask'],
- $red,
- $green,
- $blue,
- $alpha
- );
- $bg = imagecolorallocatealpha(
- $image['combo'],
- 0,
- 0,
- 0,
- 127
- );
- */
- $row=0;
- $col=0;
- while( $row < $height['combo'] )
- {
- while( $col < $width['combo'] )
- {
- //pseudocode:
- //if pixel in $image['mask'] at ($cow,$row) is white:
- //set pixel in $image['combo'] at ($cow,$row) as fully transparent
- //else
- //set pixel in $image['combo'] at ($cow,$row) as pixel color in $image['rgb'] at ($cow,$row) with full opacity
- if($col = width$['combo'] - 1)
- {
- break;
- }
- $col++;
- }
- if($row = height$['combo'] - 1)
- {
- break;
- }
- $row++;
- }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement