473,800 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GD Functions leaving lines in graphics

69 New Member
Ok all, I have a question regarding the gd library in php. First, let me say that there is really no reason why I am doing this the way that I am. I was a little bored with doing homework and thought to myself, hey I wonder if I can put a background images into parts of a webpage using css pointing to php files. So I set out to answer the question that was burning away at me... :)

Anyways, here is the code I am using to create the background for the top of a web page, 120px high. The final png is made up of smaller 5px high pngs that have a slight color change, giving the final effect of a little fade, if you will....

Expand|Select|Wrap|Line Numbers
  1. header ("Content-type: image/png");
  2.  
  3. $bg = imagecreatetruecolor(100, 120);
  4. $back = imagepng($bg, "bg.png");
  5. $back = imagecreatefrompng("bg.png");
  6.  
  7. $color = 232;
  8. $x = 0;
  9.  
  10. while ($x < 120) {
  11. $im = imagecreatetruecolor(100, 5);
  12. $fill = imagecolorallocate($im, 0, 0, $color);
  13. imagefill($im, 0, 0, $fill);
  14. imagepng($im, "add.png");
  15. $one = imagecreatefrompng("add.png");
  16. imagecopy($back, $one, 0, $x, 0, 0, 100, 10);
  17. imagepng($back, "bg.png");    
  18. $x = $x + 5;
  19. $color = $color + 1;    
  20. imagedestroy($im);
  21. imagedestroy($one);
  22. }
  23. imagepng($back);
  24. imagedestroy($back);
  25. imagedestroy($bg);
  26. ?>
  27.  
  28.  
Now the problem I run into intermittently is that every so often when the page loads, it doesn't render all the lines into the final png correctly. The color gets messed up in the smaller image and then the messed up smaller image gets added into the final image having the wrong color.

Any thoughts on why this might be or what is causing this?
Nov 12 '07 #1
2 1144
pbmods
5,821 Recognized Expert Expert
Heya, Lumpy.

Do you have a screenshot of what it looks like vs. what it's supposed to look like?
Nov 12 '07 #2
Lumpy
69 New Member
Heya, Lumpy.

Do you have a screenshot of what it looks like vs. what it's supposed to look like?
So, I got the problem solved. I was in the process of making some screen shots that I would be able to post, so you would be able to see what I was doing and what I meant by the problem I was having. When I noticed a little pattern. When the lines showed up in the overall png, It matched up with another part of the site, in which I am also using the same process to make the background. Noticing this I examined the code from both files again, and realized that I was using the same file name for the temp png, "add.png", opps. What was happening was it was grabbing the wrong "add.png" and inserting it into the whole png. Long story short, I changed the temp file name and now everything works perfectly.

Thank You for your inspiration!!!
Nov 12 '07 #3

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

Similar topics

99
5928
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
30
19758
by: Will Pittenger | last post by:
Does C# inline functions? I do not see a inline keyword. Is there an implicit inline? Can the compiler select functions for auto-inlining? I am more used to C++ where all these things are possible. ---------- Will Pittenger E-Mail: mailto:will.pittenger@verizon.net All mail filtered by Qurb (www.qurb.com)
2
20979
by: Tomomichi Amano | last post by:
Hello How can I delete (clear) lines that were made useing Graphics.DrawLine() ? Thanks in advance! Have a nice day!
5
2735
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the puck moving around. I want the puck is bounce when it hits a border (specified by the hitlines). Retreieved some info on hit testing lines from Bob Powell's GDI+ FAQ (very useful!) but i'm fairly new at the idea of hit testing and am
9
3184
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
1
1185
by: Craig Lucas | last post by:
Im kind of new to vb.net drawing routines. Im reading a collection of 2d points from a proprietary file. These points are simply for drawing lines, I can draw the lines fine using Graphics.DrawLine, but I need to scale all the lines to fit a rectangle of a given width and height. What is the best method to do something like this? Its also important that the drawing retain proportion within the given rectangle. Thanks
35
2348
by: Francine.Neary | last post by:
I'm finding it really hard to keep some of these things straight... For example, fputs is to puts as fprintf is to printf, except that fputs has the file handle at the end and fprintf at the beginning! Very illogical! And hard to remember. Now this can quite easily be corrected by macros, for example: #include <stdio.h> #define fputs(X,Y) fputs(Y,X)
1
1746
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I want to make a "GRAPHICS PROGRAM" in C language that shows sorting of lines. Something like this:- ------------ ------------------- ------ ------------------------------------ after sorting the lines should appear as follows on the screen :-
1
2022
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I want to make a "GRAPHICS PROGRAM" in C language that shows sorting of lines. Something like this:- ------------ ------------------- ------ ------------------------------------ after sorting the lines should appear as follows on the screen :-
0
9551
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
10276
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
10253
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
9090
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...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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

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.