Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
PHP: LVL to PNG/JPG

 
Post new topic   Reply to topic Printable version
 View previous topic  EZ Image Rotator Post :: Post SubStats  View next topic  
Author Message
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Wed Jun 01, 2005 2:27 am    Post subject: PHP: LVL to PNG/JPG Reply to topic Reply with quote

Quote:
File: lvl2img.php
Creator: CypherJF (ssCypherJF@yahoo.com)
URL: http://cypherjf.sscentral.com
Version: 1.1
Source: Released.

* This PHP (www.php.net) script will take a Subspace LVL mapfile and create a PNG, or JPG output.

* This source-code was originally designed to be closed-source and therefore includes a Copyright notice on all image outputs. If you must remove it, so be it - but keep the header of this document in-tact.

* This script was -never- meant to be the most efficient PHP script known to man, but it completed the task I needed to accomplish. See the usage notes below, Enjoy.

Code: Show/Hide
Usage:
lvl2img.php?file=mapname[&width=[#]][&height=[#]][&grayscale=[#]]
-- NOTE(s)--
  * Must specify a default map file (with the extention .lvl)
  : file=<mapname>
     : do not include ".lvl"
     : will use default map, if this arguement (or file) does not exist.
     : must reside in the same directory as the script.
     : NOTE: I believe, PHP ignores variables that begin with # in the $_GET[] field.
  : width=<number>
     : * optional*
     : default: 1024
  : height=<number>
     : * optional *
     : default: 1024
  : grayscale=<#>
     : 0 (default) no; otherwise, 1.


Final Note: If you see a message that states 'Invalid Map Data. Checksum != 0.' This means that the map, or LVL, file that you tried to use appears to be corrupted and can not be deconverted.

Changes
Version 1.1 - DEFAULT_MAP arguement logic fixed by MMaverick.
- Changed a lot of " to '.
- Verified script w/ E_ALL.
. Only 1 issue left "Warning: imagecolorsforindex(): Color index # out of range in <file>"
- Added comments.

Version 1.0 - Initial.


Requires that the PHP Extension php_gd2.dll be enabled in your php.ini.
_________________
Performance is often the art of cheating carefully. - James Gosling




lvl2img.v1.1.zip by CypherJF (Applied MMaverick patch, cleaned source up a bit.)

lvl2img.v1.1.zip - 3.39 KB
File downloaded or viewed 81 time(s)

lvl2img.php 1.0 by CypherJF

lvl2img.zip - 2.91 KB
File downloaded or viewed 51 time(s)


Last edited by CypherJF on Wed Jun 01, 2005 12:41 pm, edited 2 times in total
Back to top
View users profile Send private message Add User to Ignore List
Maverick
broken record


Age:39
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Wed Jun 01, 2005 5:26 am    Post subject: Reply to topic Reply with quote

icon_eek.gif That's awesome biggrin.gif
very nice

I tried it on http://www.17thparallel.com/mav only it gave the same error over and over.

http://www.17thparallel.com/mav/lvl2img.php?file=17thmainmap
Quote:
Missing Default Map: omega1.lvl

Am I doing something wrong here?
_________________
Nickname: Maverick (I changed my name!)
TWCore developer | Subspace statistics
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Maverick
broken record


Age:39
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Wed Jun 01, 2005 5:38 am    Post subject: Reply to topic Reply with quote

FIXED:

Please replace:
Code: Show/Hide
$map_name = $_GET["file"].".lvl";
if (!file_exists(DEFAULT_MAPNAME))
  die("Missing Default Map: <i>".DEFAULT_MAPNAME."</i>");

if (!file_exists($map_name))
  $map_name = DEFAULT_MAPNAME;


with:
Code: Show/Hide
$map_name = $_GET["file"].".lvl";
if (!file_exists($map_name)) {
  $map_name = DEFAULT_MAPNAME;
   if (!file_exists(DEFAULT_MAPNAME))
     die("Missing Default Map: <i>".DEFAULT_MAPNAME."</i>");
}
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:36
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Wed Jun 01, 2005 5:48 am    Post subject: Reply to topic Reply with quote

I think Dust made this once too, anyway, good job.

I don't like your double quotes though, but I don't want to be bitchy. tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Wed Jun 01, 2005 12:43 pm    Post subject: Reply to topic Reply with quote

Okay, I added the 'patch' from MMaverick in 1.1. I also used report E_ALL for testing out where things should be 'fixed'. There was only 1 warning remaining when using greyscale, but that doesn't bother me. icon_smile.gif I also moved everything from raw $_GET[] to $_CLEAN[] - you'll see what I mean if you can read PHP. icon_smile.gif Also added a few comments here and there.

Enjoy.
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Wed Jun 01, 2005 3:07 pm    Post subject: Reply to topic Reply with quote

Does it do the palette index stuff like FACTS?
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Wed Jun 01, 2005 3:09 pm    Post subject: Reply to topic Reply with quote

I doubt it does. Though I do have it use the same color value as the FACTs output - or for the most part. If you know how to do this - feel free to edit the script - and give me the code to find/replace - and I'll update it accordingly.

I bet you using the:

bool imagecolorset ( resource image, int index, int red, int green, int blue)

You could be able to setup the palette accordingly...
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Misc User Apps All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 613 page(s) served in previous 5 minutes.

phpBB Created this page in 0.467203 seconds : 34 queries executed (89.2%): GZIP compression disabled