Hi all,
I have a dynamic image that picks out data from a dynamically created .line file.
showimage.php(5 ) -
<?php
-
include("linesfile.php5");
-
$linesDataFile = new DataFile("data.line");
-
-
//$image = ImageCreate(660,240); // create the image canvas
-
$image = ImageCreateFromPNG("background.png");
-
$blue = ImageColorAllocate($image, 200, 200, 255); // prepare some blueness
-
$black = ImageColorAllocate($image, 0, 0, 0); // ... and whiteness
-
-
$cur_line_y = 63; // This stores how far down the image the current line will print
-
$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 = 15; // This is how much to move down to print the next line
-
$pagelinelimit = 12; // This is the maximum number lines of text that can be displayed
-
-
ImageFill($image, 0, 0, $blue); // fill the canvas
-
-
//ImageString($image, 3, 15, $cur_line_y, trim(stripslashes($wordwrapped[0])), $black);
-
-
$numberOfLines = $pagelinelimit;
-
-
-
-
for($i=0;$i<$numberOfLines;$i++) {
-
$data = $linesDataFile->getReverseIterate();
-
if (count($data)==0) continue;
-
$name = "[" . $data[0] . "] ";
-
$color = $data[1];
-
$font = $data[2];
-
$line = $data[3];
-
-
$line = $name . $line;
-
-
-
-
//ImageString($image, 2, $cur_line_x, $cur_line_y, trim($line), getColor($color));
-
-
-
imagettftext($image,10,0,$cur_line_x,$cur_line_y,getColor($color),getfont($font),trim($line));
-
-
$cur_line_y += $lineheight;
-
-
}
-
-
function getColor($color) {
-
global $image;
-
-
switch($color) {
-
case "black" :
-
return ImageColorAllocate($image, 0, 0, 0);
-
case "white" :
-
return ImageColorAllocate($image, 255, 255, 255);
-
case "blue" :
-
return ImageColorAllocate($image, 0, 0, 205);
-
case "red" :
-
return ImageColorAllocate($image, 255, 0, 0);
-
case "yellow" :
-
return ImageColorAllocate($image, 255, 255, 0);
-
case "green" :
-
return ImageColorAllocate($image, 0, 255, 0);
-
case "orange" :
-
return ImageColorAllocate($image, 255, 127, 36);
-
case "aqua" :
-
return ImageColorAllocate($image, 0, 255, 255);
-
default:
-
return ImageColorAllocate($image, 255, 255, 255);
-
-
}
-
}
-
-
function getfont($font) {
-
global $image;
-
global $font;
-
-
switch($font) {
-
case "fixedsys" :
-
return "fixedsys.ttf";
-
case "Courbd" :
-
return "courbd.ttf";
-
case "arial" :
-
return "arialbd.ttf";
-
case "timesnr" :
-
return "timesbd.ttf";
-
case "calibri" :
-
return "calibrib.ttf";
-
case "comicsans" :
-
return "comicsans.ttf";
-
case "palab" :
-
return "palab.ttf";
-
default:
-
return "courbd.ttf";
-
}
-
}
-
-
-
header("Content-Type: image/png"); // tell the browser what we're gonna give it
-
ImagePng($image); // paint the image in browser
-
ImagePng($image, "./chatbox.png"); //export as png file
-
ImageDestroy($image); // clean up resources
-
?>
the php in Index.php -
<?php
-
include("linesfile.php5");
-
$filename = "data.line";
-
set_magic_quotes_runtime(0);
-
if ($_POST['submit']) {
-
// grab the inputted text
-
$text = stripcslashes($_POST['input'] . "\n");
-
$username = stripslashes($_POST['username']);
-
$color = $_POST['color'];
-
$font = $_POST['font'];
-
$ip = $_SERVER['REMOTE_ADDR'] . "\n";
-
$_SESSION['username'] = $username;
-
$_SESSION['color'] = $color;
-
-
-
$dirty = array('many', 'bad', 'words', 'in', 'here'); // I took out the real array just to keep the thread 'clean'.
-
-
foreach($dirty AS $bad_word){
-
$text = preg_replace("/$bad_word/i","****", $text);
-
}
-
$data[] ="\n".$username;
-
$data[] =trim($color);
-
$data[] =trim($font);
-
$data[] =trim($text);
-
-
-
$datafile = new DataFile($filename);
-
if(!$datafile->writeNewLine($data)) die("Error writing to file");
-
}
-
?>
my plan/idea is to impliment smilies into the image. If the user enters data such as 'Yay, it works!! =D' it will replace '=D' with a .gif image.
To do this I believe I will use Imagecopymerge( ). but how would I go about getting the X & Y co-ords for the text that needs changing, in this case '=D'? Baring in mind that everytime a new post is submitted the previous line is moved down.
How would I do this?
Thanks,
Sam myChatbox - the site, just so you get a feel for the image and input
1 1767 pbmods 5,821
Recognized Expert Expert
Heya, Sam.
No good way to do it that I know of. I think you're hitting the limit of what a graphical chatbox can do.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Han |
last post by:
Determining the pattern below has got my stumped.
I have a page of HTML and need to find all occurrences of the following
pattern:
score=9999999999&
The number shown can be 5-10 characters in length. I would like to extract
only the number, stripping off the "score=" and "&".
|
by: Glutinous |
last post by:
I've been studying this for hours, searching the www & usenet, and
still can't figure out why 'each' returns an array of four key/value
pairs, when it looks like just two pairs would suffice...
That is, it looks to me like
&
are the same, and also
& ,
so what's the point of duplicating them?
|
by: Pete |
last post by:
I'm working (playing) on a mouse following script. Yes, the sort no
one likes but I'm having great fun tinkering with it - sad.
Anyway, if there's enough page content to cause scrolling and I want
the objects (colored divs) to scroll with the mouse in Opera 6. I give
the mouse y coords (-) window.pageYOffset and the objects (+)
window.pageYOffset.
However, in Opera 7 it doesn't work. Only the following objects need
(+)...
|
by: kinne |
last post by:
The following code is supposed to reverse the date in "yyyy-mm-dd" format,
but it produces different results in Firefox 1.0 and in Internet Explorer
6SP1. In Firefox, the result is correct ("2004-11-29") but it's wrong in
Internet Explorer 6SP1 ("00:20:15-11-29"). If I change "dateParts" to
"dateParts", it's exactly the opposite that occures: a correct result in
IExplorer but a fault in Firefox. Is there a workaround? Where do I miss the...
|
by: John M |
last post by:
hi,
I'm finding this problem most frustrating. (It's probably my lack of
undersating of functions!) I want to fill a control in a report with the
result of a function. I'm calculating the average of a number of fields for
the current record. It all works .. to a point!! Using for and next I can
identify the fileds and get the data. All is fine until the fields are
empty or null (I'm not quite sure.) all I get back is 'error' in the...
| |
by: Daniel Vallstrom |
last post by:
I'm having problems with inconsistent floating point behavior
resulting in e.g.
assert( x > 0.0 && putchar('\n') && x == 0.0 );
holding. (Actually, my problem is the dual one where I get
failed assertions for assertions that at first thought ought
to hold, but that's not important.)
At the end is a full program containing the above seemingly
|
by: Paminu |
last post by:
In math this expression:
(a < b) && (b < c)
would be described as:
a < b < c
But why is it that in C these two expressions evaluate to something
different for the same values of a, b and c?
|
by: find clausen |
last post by:
How can I use this:
if (!zxmes && self.name != "menu")
and add if (zmes == 1)
if (!zxmes && self.name != "menu" || zmes == 1)
and make it work.
|
by: Paul Sijben |
last post by:
I am running a multi-threaded python application in a dual core intel
running Ubuntu.
I am using python 2.5.1 that I compiled myself. At random points I am
getting segmentation faults (sometimes indicating a duplicate free).
Below is the backtrace of the latest segfault.
I am thinking this might be an issue related to the dual core CPU so I
am now running the app with affinity to one CPU to test this hypothesis.
|
by: mansi sharma |
last post by:
create table mail3(email varchar(50))
insert into mail3 values('mansi.sharma@yahoo.co.in')
insert into mail3 values('mansi.sharma+yahoo.co.in')
insert into mail3 values('mansi.sharma^yahoo.co.in')
insert into mail3 values('mansi.sharma*yahoo.co.in')
insert into mail3 values('mansi.sharma&yahoo.co.in')
insert into mail3 values('mansi.sharma!yahoo.co.in')
insert into mail3 values('mansi&sharma!yahoo.co.in')
select * from mail3
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |