Author |
Message |
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Wed Jun 01, 2005 2:27 am Post subject: PHP: LVL to PNG/JPG |
|
|
|
|
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.
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 82 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 |
|
|
Maverick
Age:39 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
|
Back to top |
|
|
Maverick
Age:39 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Wed Jun 01, 2005 5:38 am Post subject: |
|
|
|
|
FIXED:
Please replace:
$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:
$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 |
|
|
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.
Age:36 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Wed Jun 01, 2005 5:48 am Post subject: |
|
|
|
|
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.
|
|
Back to top |
|
|
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Wed Jun 01, 2005 12:43 pm Post subject: |
|
|
|
|
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. I also moved everything from raw $_GET[] to $_CLEAN[] - you'll see what I mean if you can read PHP. Also added a few comments here and there.
Enjoy.
|
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Wed Jun 01, 2005 3:07 pm Post subject: |
|
|
|
|
Does it do the palette index stuff like FACTS? _________________
|
|
Back to top |
|
|
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Wed Jun 01, 2005 3:09 pm Post subject: |
|
|
|
|
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 |
|
|
|