phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

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.

Need to make NulAvatar save two images.


 
Search this topic... | Search General Support... | Search Box
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Author Message
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Mon Jun 22, 2009 8: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



PostPosted: Tue Jun 30, 2009 9: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


flag
PostPosted: Tue Jun 30, 2009 9: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



PostPosted: Tue Jun 30, 2009 11: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


flag
PostPosted: Thu Jul 02, 2009 6:55 pm 
Post subject: Re: Need to make NulAvatar save two images.

That's something to do with the width of the image canvas.

How wide are your avatars? That one with the black line says that it is 151px.

_________________
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



PostPosted: Thu Jul 02, 2009 11: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


flag
PostPosted: Sun Jul 05, 2009 8:23 pm 
Post subject: Re: Need to make NulAvatar save two images.

I don't know, then. The only time I've gotten extra black (or any other color) around the edges was when the dimensions weren't right.
_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL Mac 512K Blog Mac GUI
Back to top
Display posts from previous:   
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0278 seconds using 15 queries. (SQL 0.0026 Parse 0.0009 Other 0.0244)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo