Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
2b601211
Commit
2b601211
authored
Jun 16, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BlankImage and ImageValueToImage
parent
4f162a1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
23 deletions
+70
-23
src/gfx/generated_image.cpp
src/gfx/generated_image.cpp
+41
-2
src/gfx/generated_image.hpp
src/gfx/generated_image.hpp
+29
-21
No files found.
src/gfx/generated_image.cpp
View file @
2b601211
...
@@ -19,6 +19,19 @@
...
@@ -19,6 +19,19 @@
ScriptType
GeneratedImage
::
type
()
const
{
return
SCRIPT_IMAGE
;
}
ScriptType
GeneratedImage
::
type
()
const
{
return
SCRIPT_IMAGE
;
}
String
GeneratedImage
::
typeName
()
const
{
return
_TYPE_
(
"image"
);
}
String
GeneratedImage
::
typeName
()
const
{
return
_TYPE_
(
"image"
);
}
// ----------------------------------------------------------------------------- : BlankImage
Image
BlankImage
::
generate
(
const
Options
&
opt
)
const
{
Image
img
(
opt
.
width
,
opt
.
height
);
img
.
InitAlpha
();
memset
(
img
.
GetAlpha
(),
0
,
opt
.
width
*
opt
.
height
);
return
img
;
}
bool
BlankImage
::
operator
==
(
const
GeneratedImage
&
that
)
const
{
const
BlankImage
*
that2
=
dynamic_cast
<
const
BlankImage
*>
(
&
that
);
return
that2
;
}
// ----------------------------------------------------------------------------- : LinearBlendImage
// ----------------------------------------------------------------------------- : LinearBlendImage
Image
LinearBlendImage
::
generate
(
const
Options
&
opt
)
const
{
Image
LinearBlendImage
::
generate
(
const
Options
&
opt
)
const
{
...
@@ -145,12 +158,12 @@ SymbolToImage::~SymbolToImage() {}
...
@@ -145,12 +158,12 @@ SymbolToImage::~SymbolToImage() {}
Image
SymbolToImage
::
generate
(
const
Options
&
opt
)
const
{
Image
SymbolToImage
::
generate
(
const
Options
&
opt
)
const
{
// TODO : use opt.width and opt.height?
// TODO : use opt.width and opt.height?
if
(
!
opt
.
symbo
l_package
)
throw
ScriptError
(
_
(
"Can only load images in a context where an image is expected"
));
if
(
!
opt
.
loca
l_package
)
throw
ScriptError
(
_
(
"Can only load images in a context where an image is expected"
));
SymbolP
the_symbol
;
SymbolP
the_symbol
;
if
(
filename
.
empty
())
{
if
(
filename
.
empty
())
{
the_symbol
=
default_symbol
();
the_symbol
=
default_symbol
();
}
else
{
}
else
{
the_symbol
=
opt
.
symbo
l_package
->
readFile
<
SymbolP
>
(
filename
);
the_symbol
=
opt
.
loca
l_package
->
readFile
<
SymbolP
>
(
filename
);
}
}
return
render_symbol
(
the_symbol
,
*
variation
->
filter
,
variation
->
border_radius
);
return
render_symbol
(
the_symbol
,
*
variation
->
filter
,
variation
->
border_radius
);
}
}
...
@@ -160,3 +173,29 @@ bool SymbolToImage::operator == (const GeneratedImage& that) const {
...
@@ -160,3 +173,29 @@ bool SymbolToImage::operator == (const GeneratedImage& that) const {
&&
age
==
that2
->
age
&&
age
==
that2
->
age
&&
variation
==
that2
->
variation
;
&&
variation
==
that2
->
variation
;
}
}
// ----------------------------------------------------------------------------- : ImageValueToImage
ImageValueToImage
::
ImageValueToImage
(
const
String
&
filename
,
Age
age
)
:
filename
(
filename
),
age
(
age
)
{}
ImageValueToImage
::~
ImageValueToImage
()
{}
Image
ImageValueToImage
::
generate
(
const
Options
&
opt
)
const
{
// TODO : use opt.width and opt.height?
if
(
!
opt
.
local_package
)
throw
ScriptError
(
_
(
"Can only load images in a context where an image is expected"
));
Image
image
;
if
(
!
filename
.
empty
())
{
InputStreamP
image_file
=
opt
.
local_package
->
openIn
(
filename
);
image
.
LoadFile
(
*
image_file
);
}
if
(
!
image
.
Ok
())
{
image
=
Image
(
opt
.
width
,
opt
.
height
);
}
return
image
;
}
bool
ImageValueToImage
::
operator
==
(
const
GeneratedImage
&
that
)
const
{
const
ImageValueToImage
*
that2
=
dynamic_cast
<
const
ImageValueToImage
*>
(
&
that
);
return
that2
&&
filename
==
that2
->
filename
&&
age
==
that2
->
age
;
}
src/gfx/generated_image.hpp
View file @
2b601211
...
@@ -27,15 +27,15 @@ class GeneratedImage : public ScriptValue {
...
@@ -27,15 +27,15 @@ class GeneratedImage : public ScriptValue {
public:
public:
/// Options for generating the image
/// Options for generating the image
struct
Options
{
struct
Options
{
Options
(
int
width
=
0
,
int
height
=
0
,
Package
*
package
=
nullptr
,
Package
*
symbo
l_package
=
nullptr
,
PreserveAspect
preserve_aspect
=
ASPECT_STRETCH
,
bool
saturate
=
false
)
Options
(
int
width
=
0
,
int
height
=
0
,
Package
*
package
=
nullptr
,
Package
*
loca
l_package
=
nullptr
,
PreserveAspect
preserve_aspect
=
ASPECT_STRETCH
,
bool
saturate
=
false
)
:
width
(
width
),
height
(
height
),
preserve_aspect
(
preserve_aspect
),
saturate
(
saturate
),
package
(
package
),
symbol_package
(
symbo
l_package
)
:
width
(
width
),
height
(
height
),
preserve_aspect
(
preserve_aspect
),
saturate
(
saturate
),
package
(
package
),
local_package
(
loca
l_package
)
{}
{}
int
width
,
height
;
///< Width to force the image to, or 0 to keep the width of the input
int
width
,
height
;
///< Width to force the image to, or 0 to keep the width of the input
PreserveAspect
preserve_aspect
;
PreserveAspect
preserve_aspect
;
bool
saturate
;
bool
saturate
;
Package
*
package
;
///< Package to load images from
Package
*
package
;
///< Package to load images from
Package
*
symbol_package
;
///< Package to load symbol
s from
Package
*
local_package
;
///< Package to load symbols and ImageValue image
s from
};
};
/// Generate the image
/// Generate the image
...
@@ -47,12 +47,21 @@ class GeneratedImage : public ScriptValue {
...
@@ -47,12 +47,21 @@ class GeneratedImage : public ScriptValue {
inline
bool
operator
!=
(
const
GeneratedImage
&
that
)
const
{
return
!
(
*
this
==
that
);
}
inline
bool
operator
!=
(
const
GeneratedImage
&
that
)
const
{
return
!
(
*
this
==
that
);
}
/// Can this image be generated safely from another thread?
/// Can this image be generated safely from another thread?
virtual
bool
threadSafe
()
const
=
0
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
;
virtual
ScriptType
type
()
const
;
virtual
ScriptType
type
()
const
;
virtual
String
typeName
()
const
;
virtual
String
typeName
()
const
;
};
};
// ----------------------------------------------------------------------------- : BlankImage
/// An image generator that returns a blank image
class
BlankImage
:
public
GeneratedImage
{
public:
virtual
Image
generate
(
const
Options
&
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
};
// ----------------------------------------------------------------------------- : LinearBlendImage
// ----------------------------------------------------------------------------- : LinearBlendImage
/// An image generator that linearly blends two other images
/// An image generator that linearly blends two other images
...
@@ -64,8 +73,6 @@ class LinearBlendImage : public GeneratedImage {
...
@@ -64,8 +73,6 @@ class LinearBlendImage : public GeneratedImage {
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
ImageCombine
combine
()
const
;
virtual
ImageCombine
combine
()
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
private:
private:
GeneratedImageP
image1
,
image2
;
GeneratedImageP
image1
,
image2
;
double
x1
,
y1
,
x2
,
y2
;
double
x1
,
y1
,
x2
,
y2
;
...
@@ -82,8 +89,6 @@ class MaskedBlendImage : public GeneratedImage {
...
@@ -82,8 +89,6 @@ class MaskedBlendImage : public GeneratedImage {
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
ImageCombine
combine
()
const
;
virtual
ImageCombine
combine
()
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
private:
private:
GeneratedImageP
light
,
dark
,
mask
;
GeneratedImageP
light
,
dark
,
mask
;
};
};
...
@@ -99,8 +104,6 @@ class CombineBlendImage : public GeneratedImage {
...
@@ -99,8 +104,6 @@ class CombineBlendImage : public GeneratedImage {
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
ImageCombine
combine
()
const
;
virtual
ImageCombine
combine
()
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
private:
private:
GeneratedImageP
image1
,
image2
;
GeneratedImageP
image1
,
image2
;
ImageCombine
image_combine
;
ImageCombine
image_combine
;
...
@@ -117,8 +120,6 @@ class SetMaskImage : public GeneratedImage {
...
@@ -117,8 +120,6 @@ class SetMaskImage : public GeneratedImage {
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
ImageCombine
combine
()
const
;
virtual
ImageCombine
combine
()
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
private:
private:
GeneratedImageP
image
,
mask
;
GeneratedImageP
image
,
mask
;
};
};
...
@@ -134,8 +135,6 @@ class SetCombineImage : public GeneratedImage {
...
@@ -134,8 +135,6 @@ class SetCombineImage : public GeneratedImage {
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
ImageCombine
combine
()
const
;
virtual
ImageCombine
combine
()
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;}
private:
private:
GeneratedImageP
image
;
GeneratedImageP
image
;
ImageCombine
image_combine
;
ImageCombine
image_combine
;
...
@@ -151,8 +150,6 @@ class PackagedImage : public GeneratedImage {
...
@@ -151,8 +150,6 @@ class PackagedImage : public GeneratedImage {
{}
{}
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
private:
private:
String
filename
;
String
filename
;
};
};
...
@@ -167,8 +164,6 @@ class BuiltInImage : public GeneratedImage {
...
@@ -167,8 +164,6 @@ class BuiltInImage : public GeneratedImage {
{}
{}
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
threadSafe
()
const
{
return
true
;
}
private:
private:
String
name
;
String
name
;
};
};
...
@@ -185,8 +180,6 @@ class SymbolToImage : public GeneratedImage {
...
@@ -185,8 +180,6 @@ class SymbolToImage : public GeneratedImage {
#ifdef __WXGTK__
#ifdef __WXGTK__
virtual
bool
threadSafe
()
const
{
return
false
;
}
virtual
bool
threadSafe
()
const
{
return
false
;
}
#else
virtual
bool
threadSafe
()
const
{
return
true
;
}
#endif
#endif
private:
private:
SymbolToImage
(
const
SymbolToImage
&
);
// copy ctor
SymbolToImage
(
const
SymbolToImage
&
);
// copy ctor
...
@@ -195,5 +188,20 @@ class SymbolToImage : public GeneratedImage {
...
@@ -195,5 +188,20 @@ class SymbolToImage : public GeneratedImage {
SymbolVariationP
variation
;
SymbolVariationP
variation
;
};
};
// ----------------------------------------------------------------------------- : ImageValueToImage
/// Use an image from an ImageValue as an image
class
ImageValueToImage
:
public
GeneratedImage
{
public:
ImageValueToImage
(
const
String
&
filename
,
Age
age
);
~
ImageValueToImage
();
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
private:
ImageValueToImage
(
const
ImageValueToImage
&
);
// copy ctor
String
filename
;
Age
age
;
///< Age the symbol was last updated
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment