GTAMP.com

Grand Theft Auto Media Press
It is currently Tue May 21, 2013 3:19 am

All times are UTC




Post new topic Reply to topic  [ 345 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16 ... 18  Next
Author Message
PostPosted: Sun Dec 04, 2011 11:51 pm 
Offline
User avatar

Joined: Mon May 18, 2009 9:40 pm
Posts: 390
Location: Nowhere.
Pyro wrote:
Interesting.

I know it's not complete but it seems the colour options don't seem to do anything yet? Guessing that's coming in future...

Neither do the background options. +1 for "coming in the future"

_________________
You just lost the game.


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 3:06 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Yeah not done yet. Im doing the coloring atm.

Edit: works:
Image

Code:
generate_colors.php:
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
<?php

$img = imagecreatefrompng("r.png");

$count = 18;
$sx = 2;
$sy = 6;
$step = 9;

$xpos = $sx;

$colors = array();
for($u = 0; $u < $count; $u++){
    $color_border = imagecolorat($img, $xpos-1, $sy);
    $color_high = imagecolorat($img, $xpos, $sy);
    $color_high_mix = imagecolorat($img, $xpos+1, $sy);
    $color_main = imagecolorat($img, $xpos, $sy+1);
    $colors[] = array($color_border, $color_main, $color_high, $color_high_mix);
    $xpos += $step;
}
imagedestroy($img);

for($u = 1; $u < $count; $u++){
    $img = imagecreatefrompng("gta2font_normal.png");
    imagesavealpha($img, true);
    $width = imagesx($img);
    $height = imagesy($img);

    for($y = 0; $y < $height; $y++){
        for($x = 0; $x < $width; $x++){
            $color = imagecolorat($img, $x, $y);
            if($color == $colors[0][0]){
                imagesetpixel($img, $x, $y, $colors[$u][0]);
            }else if($color == $colors[0][1]){
                imagesetpixel($img, $x, $y, $colors[$u][1]);
            }else if($color == $colors[0][2]){
                imagesetpixel($img, $x, $y, $colors[$u][2]);
            }else if($color == $colors[0][3]){
                imagesetpixel($img, $x, $y, $colors[$u][3]);
            }
        }
    }
    imagepng($img, "gta2font_normal_c{$u}.png");
    imagedestroy($img);
}

?>
Parsed in 0.084 seconds, using GeSHi 1.0.8.10


gta2text.php (replace the normal font loader):
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
// load font (and get $font_height at same time):
if($font_style == 0 && $color_style > 0 && $color_style < 18){
    $fnt = imagecreatefrompng("gta2font_normal_c{$color_style}.png");
}else{
    $fnt = imagecreatefrompng("gta2font_{$typestr}.png");
}
Parsed in 0.079 seconds, using GeSHi 1.0.8.10

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 4:13 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Color codes work now:
Image

Code:
This [17]EPIC [16]coloring [15]does [14]indeed
[13]seem to [12]maybe [11]work [10]correctly [9]here
it [8]must be [7]tested [6]to be sure
[5]about the [4]fact that [3]it might
[2]not work [1]correctly at all [3]!?


http://epicgta2.omnitude.net/gta2text/? ... 3%5D%21%3F

Damn firefox messes up the URL's, how can i make it to disable "user friendly" URL's? it makes it impossible to copypaste URL ! (i had to go to IE to get correct URL...)

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 4:27 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
Wow, nice work! I found the bug for the text image not showing up on xampp lite. It complains that the index is out "of range" (not correct) which caused the image source to be corrupt, my fix is this:

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
//test if the font, color or bg are set. if not, give it an existing zero
if (isset($_GET['font'])) {
    $font_style = ((int)$_GET['font'])-1;
} else {
    $font_style = 0;
}

if (isset($_GET['color'])) {
    $color_style = ((int)$_GET['color']);
} else {
    $color_style = 0;
}

if (isset($_GET['bg'])) {
    $bg_style = ((int)$_GET['bg']);
} else {
    $bg_style = 0;
}
Parsed in 0.024 seconds, using GeSHi 1.0.8.10


Comment on the coloring: When using a colortag higher than 18 it should not display it.

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
if ($color > 18) dontDisplay();

function dontDisplay(){
//do nothing!
}
Parsed in 0.022 seconds, using GeSHi 1.0.8.10

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 4:35 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
That out of range error can be disabled by setting this on gta2text.php and index.php at first line of PHP code:
Code:
error_reporting(E_ALL ^ E_NOTICE);


Quote:
Comment on the coloring: When using a colortag higher than 18 it should not display it.

Hmm, you are right, also i found weird bug... image breaks if i use higher than 18 o_O fixing...

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 4:44 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Fixed now. I wont make it hide the incorrect color tags, so the user can see whats wrong.
Example:
Image

the font would render the [ and ] marks if there was such marks in the font! but it doesnt, so it only shows the numbers... maybe i should convert those incorrect tags into ( and ) marks?

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 4:56 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
T.M. wrote:
That out of range error can be disabled by setting this on gta2text.php and index.php at first line of PHP code:
Code:
error_reporting(E_ALL ^ E_NOTICE);



But isn't that suppressing an error?

T.M. wrote:
Fixed now. I wont make it hide the incorrect color tags, so the user can see whats wrong.
Example:
Image

the font would render the [ and ] marks if there was such marks in the font! but it doesnt, so it only shows the numbers... maybe i should convert those incorrect tags into ( and ) marks?


I would say, there is no "[" and "]" sign in the real gta2 font, so it will never show up - neither be replaced by a different sign suddenly if you typed wrong. I much rather have a small comment somewhere on the webpage saying "You entered a wrong colour-tag at line x".

//edit. which is probably a lot of work, so never mind that

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:00 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
Should we put a cap on the max length (and height)? I mean, nobody is ever going to make such a long image in normal use (see below).

Image

cap at 1920 pixels?? HD screensize?

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:02 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Quote:
But isn't that suppressing an error?
Nope, its suppresing a notice. I hate to code like this:
Code:
if(isset($_GET['lol']) && $_GET['lol'] != "")
instead of just:
Code:
if($_GET['lol'] != "")

And that "E_ALL ^ E_NOTICE" is PHP default it says. your server is bitch about errors, not all servers have same bitchyness level. :D

Quote:
//edit. which is probably a lot of work, so never mind that

Hmm, shouldnt be that much work actually, just call the render render_gta2text() in the index.php as well and set a global var inside that loop if a code was incorrect.

Quote:
Should we put a cap on the max length (and height)? I mean, nobody is ever going to make such a long image in normal use (see below).

INDEED!!! i thought of it. i will add forced newlines there for too long texts, and limit the height of total image as well.

Quote:
cap at 1920 pixels?? HD screensize?
I think 640 pixels wide is enough? (as gta2 is too).

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:08 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Fixed too wide images now. TODO: height limit. brb. afk for a while.

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:09 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
Yeah 640 is probably enough. Maybe put the variable that determines this at the top of the code with a little info, so if Sektor or somebody else takes over the code they can change that to their desire. :)

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:27 pm 
Offline
User avatar

Joined: Mon May 18, 2009 9:40 pm
Posts: 390
Location: Nowhere.
Felt like doing it:
Image


Nice work guys

_________________
You just lost the game.


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:35 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Cuban-Pete wrote:
Yeah 640 is probably enough. Maybe put the variable that determines this at the top of the code with a little info, so if Sektor or somebody else takes over the code they can change that to their desire. :)

Yeah of course ;)

Added height limit:
Image

Image

Image

Image

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 5:40 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
TODO: 256 palette optimization, should make all images 2x smaller in filesize according to my tests!

it doesnt even matter if you use colored text with all possible colors; total amount of colors is 55 in such an image!

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 6:02 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
T.M. wrote:
TODO: 256 palette optimization, should make all images 2x smaller in filesize according to my tests!

it doesnt even matter if you use colored text with all possible colors; total amount of colors is 55 in such an image!


also with background? still sounds like a good idea for normal font. [sm-42]

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 6:21 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
I made the default color to same style as the others; removed "shininess" from it. default is off. Then i added option to enable shininess for all colors:

Image - - - - Image

Can you see the difference?

--

I will add backgrounds soon.

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 7:48 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
Yes I do, but it is not super clear, also depending on colour. But isn't shiny the basic style (used in GTA2)? I kinda prefer shiny one. :)

I'm not sure if you are a fan of optimization, but I was thinking about it for a little and the follow idea. Is it perhaps a good idea to make an image with most used words in English (or perhaps other languages) and do a "pre-text-scan" before copying letters. This way words like "and", "or" etc can be added quicker and speeding up generation time of images and lowering CPU usage of the server. Of course there is no need for this optimization if the text is only 5-10 letters long (or something like that), but for the longer ones it might speed up. The size of this image with often used words is also important, because an image that is too large will only slow things down.

Another idea on optimization is that the php script is made such a way that it should NOT have to reload the "base" image(s) every time and just keep them in memory to lower amount of disk reads on the server.

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 7:56 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Such optimization would be pointless; i've made before normal text renderer with 12px font, and i was able to generate like 2000x20000 size image full of text in the same speed i loaded that same text in text format :D and the method was probably even crappier than what i use here, still, the point is: i used much more calls to imagecopy() function, which you are supposed to optimize. its true that PHP function calls are quite slow, but not that slow we need to optimize per word, the maximum image size is 800x384, no need to optimize anything. The slowness you might see comes purely from the downloading speed of that image.

Not to mention that kind of optimizations would just make more problems; for example i wouldnt be able to break the text if it makes the image too wide. and how about the memory use?? each word would need 18 different images to be loaded in worst case scenario.

I cant make PHP to preload the images into memory, its enough fast already, i dont think there is performance problems... i will check how many milliseconds it takes now to render it with full size image and all possible colors :D

ps. making the background feature now.

_________________
My GTA2 related projects:


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 8:02 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 795
Okay, so optimization in php is not noticeable, but it is in the imagesize. Did the "palette-trick" work in lower imagesize? Have you also heard about pngcrush?

_________________
"Only Silky Milky implants by Zaibatsu feel and taste like the real thing."


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 8:06 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 825
Location: F21B3EED
Its not just PHP, but in general, its very impractical in any application to pre-generate billion different word combinations (we need a lot, or else we wouldnt see any performance increase since checking only few words would actually make it slower than without the optimization). not to mention, the memory use would be epic, or you would need to load new images all the time, which makes super slow performance.

i havent tried palette trick yet, what do you mean by imagesize...? i havent heard about pngcrush, does it compress PNG better? :O

_________________
My GTA2 related projects:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 345 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16 ... 18  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group