Welcome to all phpBB2 Refugees!This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area. |
|
Author |
Message |
Acaria Board Member
Joined: 20 Feb 2009
Posts: 238
|
Posted: Mon Jun 22, 2009 4:34 pm Post subject: Need to make NulAvatar save two images. |
|
|
Okay, so I used the Alternating Replies Mod. Now the posts have avatars on opposing sides.
What I need is to have NulAvatar save two different images. One as the regular, default, but the other as a flipped version.
That way you have one angle saved as, say, "images/avatars/2.png" and the other as "images/avatars/2_flip.png".
That way I can call them on the correct side so they're facing the posts.
I found this page on the ADR site about literally the exact same thing. I just don't know how I would employ such a code.
Help? XD
[Edit]
I think I've narrowed it down to needing to make an addendum to this section of the code:
Code: |
//
// [START] At last, create the PNG image!
//
$tot_width = $width;
$tot_height = $height;
// Get all layers in the correct order!
$Lsql = "SELECT * FROM `".$table_prefix."nulavatar_layers` ORDER BY position ASC";
if ( !($Lresult = $db->sql_query($Lsql)) )
{ message_die(GENERAL_MESSAGE, "<b>Fatal Error!</b><br><br>".mysql_error()); }
$tot_layers = mysql_num_rows($Lresult);
$nulavatar = false;
for( $iii = 0; $iii < $tot_layers; $iii++ )
{
$Lrow = mysql_fetch_array($Lresult);
if($HTTP_POST_VARS[$Lrow['name']] != 'spacer.gif')
{
if($nulavatar == false)
{
$sprite_1 = @$imagecreate($phpbb_root_path.$sprites_path.'/'.$HTTP_POST_VARS[$Lrow['name']]);
$nulavatar = true;
}
else
{
$image = @$imagecreate($phpbb_root_path.$sprites_path.'/'.$HTTP_POST_VARS[$Lrow['name']]);
@imagecopy ($sprite_1, $image, 0, 0, 0, 0, $tot_width, $tot_height);
@ImageDestroy($image);
}
}
}
$save = $userdata['user_id'];
imagepng($sprite_1, $phpbb_root_path . $chars_path . '/' . $save . '.png');
imagedestroy($sprite_1);
//
// [END] At last, create the PNG image!
//
|
|
|
Back to top |
|
|
Acaria Board Member
Joined: 20 Feb 2009
Posts: 238
|
Posted: Tue Jun 30, 2009 5:16 pm Post subject: Re: Need to make NulAvatar save two images. |
|
|
Anyone? o.o; |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
Posted: Tue Jun 30, 2009 5:49 pm Post subject: Re: Need to make NulAvatar save two images. |
|
|
Sorry, didn't see this topic.
Change these lines:
Code: |
$save = $userdata['user_id'];
imagepng($sprite_1, $phpbb_root_path . $chars_path . '/' . $save . '.png');
imagedestroy($sprite_1);
|
To these:
Code: |
$save = $userdata['user_id'];
// Create a new canvas
$flip = imagecreatetruecolor($tot_width, $tot_height);
// Save alpha channels
imagealphablending($flip, false);
imagesavealpha($flip, true);
// Do the flip
imagecopyresampled($flip, $sprite_1, 0, 0, $tot_width, 0, $tot_width, $tot_height, -$tot_width, $tot_height);
imagepng($sprite_1, $phpbb_root_path . $chars_path . '/' . $save . '.png');
imagepng($flip, $phpbb_root_path . $chars_path . '/' . $save . '_flip.png');
imagedestroy($sprite_1);
imagedestroy($flip);
|
_________________ Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL • Mac 512K Blog • Mac GUI |
|
Back to top |
|
|
Acaria Board Member
Joined: 20 Feb 2009
Posts: 238
|
Posted: Tue Jun 30, 2009 7:17 pm Post subject: Re: Need to make NulAvatar save two images. |
|
|
Thank you very much, DogCow! Works almost perfectly!
There's only one problem. It's causing a black line to appear off to the side:
Image link |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
|
Back to top |
|
|
Acaria Board Member
Joined: 20 Feb 2009
Posts: 238
|
Posted: Thu Jul 02, 2009 7:25 pm Post subject: Re: Need to make NulAvatar save two images. |
|
|
That's actually the correct size.
They're 151x216 due to an, *ahem*, error with MS Paint. XD |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
|
Back to top |
|
|
|
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0445 seconds using 16 queries. (SQL 0.0088 Parse 0.0007 Other 0.0350) |
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com
|
|