473,695 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GD intermittent color problem

118 New Member
Hey folks, yet again.

[php]


if ($back == "m") //$back is a value pulled from a db; that works perfectly.
{
$wid = $rowing['width'];
$hei = $rowing['height'];
createthumb("66 0x240background 2.gif", "./user/" . $user . "_back.gif" , $wid, $hei);

$image = imagecreatefrom gif("./user/" . $user . "_back.gif" );
$blue = ImageColorAlloc ate($image, 200, 200, 255); // prepare some blueness
$black = ImageColorAlloc ate($image, 0, 0, 0); // ... and whiteness
$im = ImageCreate(300 , 35);
$black_a = imagecoloralloc ate($im, 0, 0, 0);
$white_a = imagecolortrans parent($im, $black_a);
$white = ImageColorAlloc ate($im, 255, 255, 255);
ImageFill($im, 0, 0, $white_a);
Imagettftext($i m, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");

$cur_line_y = 65; // This stores how far down the image the current line will print

$postperpage = 11;
}
elseif ($back == "u")
{
$wid = $rowing['width'];
$hei = $rowing['height'];



// createthumb("./user/".$user."_img.g if", "./user/" . $user . "_backim.gi f", $wid, $hei);

imagecreatefrom gif("./user/" . $user . "_img.gif") ;



$images = imagecreate($wi d, $hei);

$imge = imagecreatefrom gif("./user/" . $user . "_backim.gi f");

imagecopymerge( $images, $imge, 0, 0, 0, 0, $wid, $hei, 20);

imagegif($image s, "./user/" . $user . "_back_trans.gi f");

$image = imagecreatefrom gif("./user/" . $user . "_back_trans.gi f");

$im = ImageCreate(300 , 35);
$black_a = imagecoloralloc ate($im, 0, 0, 0);
$white_a = imagecolortrans parent($im, $black_a);
$white = ImageColorAlloc ate($im, 255, 255, 255);
ImageFill($im, 0, 0, $white_a);
Imagettftext($i m, 15, 0, 10, 30, $white, $font, $user . "'s Shoutbox");

$cur_line_y = 74; // This stores how far down the image the current line will print
$postperpage = 10;
}

$sql = ""; // no need for actuall SQL statement - it works.

$result = mysql_query($sq l) or die("error in sqllls: " . mysql_error());


$cur_line_x = 24; // This stores how far across the image the current line will print
$pagecharwidth = 75; // this is the maximum length of the line before it wraps;
$lineheight = 18; // This is how much to move down to print the next line
$pagelinelimit = 1; // How many of each comment appears per page.


//ImageString($im age, 3, 15, $cur_line_y, trim(stripslash es($wordwrapped[0])), $black);

$numberOfLines = $pagelinelimit;

for ($i = 0; $i < $numberOfLines; $i++)
{
while ($row = mysql_fetch_arr ay($result))
{

$name = "[" . htmlspecialchar s_decode($row['username']) . "] "; //it works - returns username
$font = $row['font']; //it works - renders the colour
$color = $row['color']; //it works - changes the font
$line = htmlspecialchar s_decode($row['comment']); //it works, posts the shout

if ($name == "[] ")
{
$name = "";

$line = $name . $line;
}
else
{
$line = $name . $line;

}

//code for emoticons.

//add shouts to image!
if ($back == "m" )
{
if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
"orange" || $color == "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));


}
elseif ($color != "white" || $color != "yellow" || $color != "green" || $color !=
"orange" || $color != "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
trim($line));


}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));


}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line));


}

}
elseif ($back == "w" )
{

$blac = imagecoloralloc ate($image, 0, 0, 0);

if ($color == "black" || $color == "purple" || $color == "blue" || $color ==
"emerald" || $color == "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));


}
elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
"emerald" || $color != "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $blac, getfont($font),
trim($line));


}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));


}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line));


}

}


[/php]

Depending on the values of $back, the background of the image changes and the font colours also change. This code works so far.

Problem code

[php]
elseif($back == "u")
{
if ($color == "white" || $color == "yellow" || $color == "green" || $color ==
"orange" || $color == "aqua")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));


}elseif ($color != "black" || $color != "purple" || $color != "blue" || $color !=
"emerald" || $color != "red")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, getfont($font),
trim($line));


}
elseif ($font == "fixedsys" || $font == "Courbd" || $font == "arial" || $font ==
"timesnr" || $font == "calibri" || $font == "comicsans" || $font == "palab")
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, getColor($color ), getfont
($font), trim($line));


}
else
{
Imagettftext($i mage, 10, 0, $cur_line_x, $cur_line_y, $white, "courbd.ttf ", trim
($line) . " ");


}
}

$cur_line_y += $lineheight;


}
}
[/php]

The problem is that when $back == "u", for the first two comments the colours are normal then after that the older comments turn black; the newest comment is in colour but it also changes the colour of the $im that says "User's Shoutbox", which is created as a seperate image.

I can't, for the life of me, see the problem.. can you?

An example: $back == "u" because it's an uploaded background. The oldest comment was white, then I added the Yellow comment, the white one turned black.

http://www.helraizer.co.uk/mychatbox/user/lucifer.gif


Hope that makes sense; if you need more code, just ask. =)
Sam
Jun 6 '08 #1
3 2079
helraizer1
118 New Member
*bump*

Any one got any ideas?

The process of the background image is that when they upload it as either jpg, gif or png; it is converted to and saved a gif file.

So I uploaded this image

http://www.helraizer.co.uk/mychatbox...ucifer_img.gif

which then is pulled into the code where $back == "u" the first time. It is the saved to the user's specified dimensions. So creates this (700x290, in this case).

http://www.helraizer.co.uk/mychatbox...fer_backim.gif

It is the merged onto a gd made image at the same dimensions, this time at 20% transparency. Which gives this:

http://www.helraizer.co.uk/mychatbox...back_trans.gif

That final, darkened image is what the shouts are written onto. Is there any way this process could be affecting the colours? I can't imagine it can because this process happens seperately each time, before the shouts are written on.

Sam


EDIT: Fixed it!

Used imagecreatetrue color($wid, $hei); instead of imagecreate(). It works perfectly now.
Jun 6 '08 #2
helraizer1
118 New Member
The imagecreatetrue colour only solved it for a little while, allowing one more comment of colour than before, now the comments do the same thing.

Any ideas why when a new comment is posted, the imagecoloralloc ate fails and the comments turn black?

supposed to be like:

http://www.helraizer.co.uk/mychatbox/user/helraizer.gif - plain background, colours work!

but ends up like:

http://www.helraizer.co.uk/mychatbox/user/lucifer.gif - detailed background, colours only work part of the time.

Please reply if you have any theories.

Sam
Jun 7 '08 #3
helraizer1
118 New Member
Fixed it again. xD

Used the same technique but this time I've made it as png. That way it doesn't run out of colours on the pallete and gives the same result.

Sam
Jun 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2153
by: Anthony | last post by:
I have a php app that is in the final stages of testing and has been tested by over 30 separate users. One of the testers is having an intermittent problem which seems to be caused by a session variable not being read properly in about 1 in 3 requests even though the variable is getting set correctly in the session temp file. It only happens after a form has been submitted (using POST or GET doesn't seem to make a difference). This...
1
2022
by: bloodhound | last post by:
Hi, Problem with global.asa not firing 100% of the time. This error crops up several times throughout the day but if you wait a while and reload the page (could be 5 mins or an hour) it will suddenly start working again. The error is: ADODB.Recordset error '800a0bb9' Arguments are of the wrong type, are out of acceptable range, or are in
2
1697
by: deevoy | last post by:
Hi- I'm developing a asp.net web application and everything has proven fine on the dev and acceptance environment. We've moved the code up to our windows server 2003 prod environment and get the following intermittent error when browsing the web page through a client browser (the action causing this is paging though a datagrid- although it randomly errors, rather than erroring all the time): ________________ Invalid character in a...
2
1112
by: gary | last post by:
I am using VS.NET 2003 on XP I intermittently get Access is denied '' at the line <add assembly="*"/> in machine.config I have disabled indexing service and I am not running any form of anti-virus software. I have looked at filemonitor from sysinternals and it tells me the aspnet_wp
8
5043
by: trinitypete | last post by:
Hi all I have a strange problem with IIS windows pass through authentication. Heres the setup IIS running with Windows Authentication for our intranet site. ACL has been set to everyone for all web directories. This is all on a windows 2003 server. We add the intranet site to the intranet zone so the windows credentials will automatically get passed to IIS 90% of the time it works fine, but Intermittently we get access forbidden -...
2
1864
by: Mike Krajewski | last post by:
We are having an intermittent problem using an ExecuteScalar command on a asp.NET page accessing SQL Server. 2 characters of the sql statement get intermittently altered. The code looks as follows: SqlCommand command = new SqlCommand("SELECT fkOWSStatusID FROM vwUsersCleanups WHERE pkCleanupID = 123", connection); object nReturn = command.ExecuteScalar(); About 10% of the time, the 'rs' in vwUsersCleanups get altered into...
3
2034
by: Lee Chapman | last post by:
Hi, I have a problem where my ASP.NET application occasionally generates a MissingFieldException exception. This unexpectedly happened on my development box, and so I was able to extract some information from the debugger: The field that is "missing" is called 'logger'. Here's it's description taken from ildasm.exe: ..field public static class log4net.ILog logger
0
1221
by: Shane C | last post by:
Intermittent Error: Server was unable to process request  Object reference not set to an instance of an object I have windows application that references a XML web service on our web server. The application sends and receives information fine most of the time. We do, mostly during peak usage hours, receive the above mentioned error. 1. What would cause the intermittent nature? 2. What can be done to fix this problem?
0
1208
by: Joey Bersche | last post by:
I've been experiencing an intermittent crash where no python stacktrace is provided. It happens for a url downloading process that can last up to 12 hours and crawls about 50,000 urls. I'm using urllib2 for the downloads. There are 5-10 downloading threads, and some custom website exploration code for providing the urls to crawl. The downloads are completed in memory (not piped), then saved to a file. There are also nice per domain...
15
5601
by: jonnyboy | last post by:
Hello, I'm having an intermittent problem with the back-end of my database. On an intermittent basis, the back-end tables will become read-only. This only happens when the back-end is located on a network share. It isn't a permissions issue because the problem occurs only intermittently when logged in as the same user. If I open the back-end database on its own and then the front-end client (on the local drive) this problem goes...
0
8572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8984
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8825
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2272
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.