Reply
GD Question WARNING: ADVANCED
Old 11-29-2007, 11:06 PM GD Question WARNING: ADVANCED
Mattmaul1992's Avatar
Ultra Talker

Posts: 440
Name: Matt
You know when you write a script and have no idea why it's not working? Well, this usually doesn't happen because the PHP god gave us error messages. If you're doing something like this in which you may not get in error message for many errors you might make it's hard, and sometimes impossible to find out what went wrong. So I want to know if you guys see any reason this script shouldn't work.
Just to explain what I want it to do - The script has an array with a character in every key (Mattmaul1992). There's a foreach loop in which the individual replacement character widths are found and the individual replacement characters source is found. After I have the final string width calculated I create a new string image and merge all the individual character images together into that new string imgae. I then merge the string image onto the background image. Why go through all this trouble? It's the only way to center the string to the pixel. Well it will be after a nice long equation.
GD scripts can get confusing and most people aren't familiar with the library so I can understand if no one can help me out but if you want a challenge here's your chance lol. Thanks.

PHP Code:
<?php
//--------------------------------------------------------------------
// BACKGROUND
// http://www.image2life.net/users/public/f30104bg_imaged182.png
//--------------------------------------------------------------------
// TO DO: Make a file for each skin which includes all the BG/character info
$skin_id 1;
$bg 'http://www.image2life.net/users/public/g22930the_bgu182.png';
$num_1 'http://www.image2life.net/users/public/q23270the_num_1w182.png';
$num_1 imageCreateFromPNG($num_1);
$bg_img imageCreateFromPNG($bg);

// Create and format the username string to be added to the main image...
$username 'Mattmaul1992';
$username_array = array('M''a''t''t''m''a''u''l''1''9''9''2');
$char_image_lib_srcs = array();
$char_widths = array();
$char_widths_current_key 0;
$string_total_width 0;
$counter 0;
foreach (
$username_array as $key => $value)
{
$image_size getImageSize($num_1);
$char_widths[$char_widths_current_key] = $image_size[0];
$string_total_width += $image_size[0];
$char_image_lib_srcs[$counter] = $num_1;
$char_widths_current_key++;
$counter++;
}
$string_img imageCreate($string_total_width14);
foreach(
$char_image_lib_srcs as $key => $value)
{
imageCopyMerge($string_img$num_1$char_widths[$key], 0001014100);
}

imageCopyMerge($bg_img$string_img5000$string_total_width14100);

/*
Funcion I'll use when an image lib is in
foreach ($username_array as $key => $value)
{
$image_size = getImageSize('/image_libs/' . $skin_id . '/characters/' . $value);
$char_widths[$char_widths_current_key] = $image_size[0];
$string_total_width += $image_size[0];
$char_image_lib_srcs[$counter] = ('/image_libs/' . $skin_id . '/characters/' . $value);
$counter++;
}*/

//imageCopyMerge($bg_img, $num_1, 5, 5, 0, 0, 10, 14, 100);
//$textcolor = imagecolorallocate($bg_img, 0, 0, 255);
//imagestring($bg_img, 5, 50, 0, $username, $textcolor);
header("Content-type: image/png");
imagePNG($bg_img);
?>
__________________
PHP Code:
$talkupation++; 
http://www.forum-front.com/ - Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Reply     « Reply to GD Question WARNING: ADVANCED
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10782 seconds with 13 queries