Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
7fc81785
Commit
7fc81785
authored
25 years ago
by
Per Hedbor
Browse files
Options
Downloads
Patches
Plain Diff
Added load_layers and decode_layers
Rev: lib/modules/_Image.pmod/module.pmod:1.5
parent
0bda168d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/_Image.pmod/module.pmod
+57
-15
57 additions, 15 deletions
lib/modules/_Image.pmod/module.pmod
with
57 additions
and
15 deletions
lib/modules/_Image.pmod/module.pmod
+
57
−
15
View file @
7fc81785
//! module Image
//! module Image
//! $Id: module.pmod,v 1.
4 1999/12/21 23:47:31
per Exp $
//! $Id: module.pmod,v 1.
5 2000/02/08 03:39:46
per Exp $
//! method object(Image.Image) load()
//! method object(Image.Image) load()
//! method object(Image.Image) load(object file)
//! method object(Image.Image) load(object file)
...
@@ -89,9 +89,39 @@ mapping _decode( string data, mixed|void tocolor )
...
@@ -89,9 +89,39 @@ mapping _decode( string data, mixed|void tocolor )
"img":i,
"img":i,
"image":i,
"image":i,
]);
]);
}
array(Image.Layer) decode_layers( string data, mixed|void tocolor )
{
array i;
if(!data)
return 0;
foreach( ({ "GIF", "JPEG", "XWD", "PNM",
"XCF", "PSD", "PNG", "BMP", "TGA", "PCX",
"XBM", "XPM", "TIFF", "ILBM", "PS",
"HRZ", "AVS", "WBF",
}), string fmt )
if( !catch(i = Image[fmt]->decode_layers( data )) && i )
break;
if(!i) // No image could be decoded at all.
catch
{
mapping q = _decode( data, tocolor );
i = ({
Image.Layer( ([
"image":q->img,
"alpha":q->alpha
]) )
});
};
return i;
}
}
string read_file(string file)
string read_file(string file)
{
{
string ext="";
string ext="";
...
@@ -121,7 +151,7 @@ string read_file(string file)
...
@@ -121,7 +151,7 @@ string read_file(string file)
return Stdio.read_file( file );
return Stdio.read_file( file );
}
}
mapp
ing
_
load
(
void|object|string file
, mixed|void opts
)
local str
ing load
_file(
void|object|string file
)
{
{
string data;
string data;
if (!file) file=Stdio.stdin;
if (!file) file=Stdio.stdin;
...
@@ -132,6 +162,12 @@ mapping _load(void|object|string file, mixed|void opts)
...
@@ -132,6 +162,12 @@ mapping _load(void|object|string file, mixed|void opts)
if( catch( data = read_file( file ) ) || !data || !strlen(data) )
if( catch( data = read_file( file ) ) || !data || !strlen(data) )
catch( data = Protocols.HTTP.get_url_nice( file )[ 1 ] );
catch( data = Protocols.HTTP.get_url_nice( file )[ 1 ] );
}
}
return data;
}
mapping _load(void|object|string file, mixed|void opts)
{
string data = load_file( file, opts );
if( !data )
if( !data )
error("Image._load: Can't open %O for input.\n",file);
error("Image._load: Can't open %O for input.\n",file);
return _decode( data,opts );
return _decode( data,opts );
...
@@ -146,6 +182,12 @@ object(Image.Layer) load_layer(void|object|string file)
...
@@ -146,6 +182,12 @@ object(Image.Layer) load_layer(void|object|string file)
return Image.Layer( (["image":m->image]) );
return Image.Layer( (["image":m->image]) );
}
}
array(Image.Layer) load_layers(void|object|string file, mixed|void opts)
{
string d = load_file( file );
return decode_layers( file, opts );
}
object(Image.Image) load(void|object|string file)
object(Image.Image) load(void|object|string file)
{
{
return _load(file)->image;
return _load(file)->image;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment