* Updated version to 0.9.17
* Stamps now supports SVG vector-based graphics! (Via Cairo library) * Discussed SVG Stamps in "Extending Tux Paint." * Created an "SVG.txt" document, covering SVG software. * Mentioned descriptive sounds (e.g., "stamp_desc_ll.ogg") in "Extending..." * Listing new www.tuxpaint.org website URL.
This commit is contained in:
parent
f802626da4
commit
b765c86e50
14 changed files with 622 additions and 120 deletions
28
Makefile
28
Makefile
|
|
@ -7,12 +7,12 @@
|
||||||
# bill@newbreedsoftware.com
|
# bill@newbreedsoftware.com
|
||||||
# http://www.newbreedsoftware.com/tuxpaint/
|
# http://www.newbreedsoftware.com/tuxpaint/
|
||||||
|
|
||||||
# June 14, 2002 - October 13, 2006
|
# June 14, 2002 - October 26, 2006
|
||||||
|
|
||||||
|
|
||||||
# The version number, for release:
|
# The version number, for release:
|
||||||
|
|
||||||
VER_VERSION=0.9.16
|
VER_VERSION=0.9.17
|
||||||
VER_DATE=`date +"%Y-%m-%d"`
|
VER_DATE=`date +"%Y-%m-%d"`
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -78,6 +78,11 @@ LOCALE_PREFIX=$(PKG_ROOT)$(PREFIX)/share/locale
|
||||||
NOSOUNDFLAG=__SOUND
|
NOSOUNDFLAG=__SOUND
|
||||||
|
|
||||||
|
|
||||||
|
# Built with SVG support (via Cairo) by default (override with "make nosvg")
|
||||||
|
|
||||||
|
NOSVGFLAG=__SVG
|
||||||
|
|
||||||
|
|
||||||
# Where to find cursor shape XBMs
|
# Where to find cursor shape XBMs
|
||||||
|
|
||||||
MOUSEDIR=mouse
|
MOUSEDIR=mouse
|
||||||
|
|
@ -91,7 +96,9 @@ CURSOR_SHAPES=LARGE
|
||||||
|
|
||||||
SDL_LIBS=$(shell sdl-config --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB)
|
SDL_LIBS=$(shell sdl-config --libs) -lSDL_image -lSDL_ttf $(SDL_MIXER_LIB)
|
||||||
SDL_MIXER_LIB=-lSDL_mixer
|
SDL_MIXER_LIB=-lSDL_mixer
|
||||||
SDL_CFLAGS=$(shell sdl-config --cflags)
|
SDL_CFLAGS=$(shell sdl-config --cflags) $(SVG_CFLAGS)
|
||||||
|
SVG_LIB=-lcairo -lsvg -lsvg-cairo
|
||||||
|
SVG_CFLAGS=-I/usr/include/cairo
|
||||||
|
|
||||||
|
|
||||||
# The entire set of CFLAGS:
|
# The entire set of CFLAGS:
|
||||||
|
|
@ -105,7 +112,7 @@ CFLAGS=-O2 -W -Wall -fno-common -ffloat-store \
|
||||||
`src/test-option.sh -Wdeclaration-after-statement`
|
`src/test-option.sh -Wdeclaration-after-statement`
|
||||||
|
|
||||||
DEFS=-DDATA_PREFIX=\"$(DATA_PREFIX)/\" \
|
DEFS=-DDATA_PREFIX=\"$(DATA_PREFIX)/\" \
|
||||||
-D$(NOSOUNDFLAG) -DDOC_PREFIX=\"$(DOC_PREFIX)/\" \
|
-D$(NOSOUNDFLAG) -D$(NOSVGFLAG) -DDOC_PREFIX=\"$(DOC_PREFIX)/\" \
|
||||||
-DLOCALEDIR=\"$(LOCALE_PREFIX)/\" -DCONFDIR=\"$(CONFDIR)/\" \
|
-DLOCALEDIR=\"$(LOCALE_PREFIX)/\" -DCONFDIR=\"$(CONFDIR)/\" \
|
||||||
-DVER_VERSION=\"$(VER_VERSION)\" \
|
-DVER_VERSION=\"$(VER_VERSION)\" \
|
||||||
-DVER_DATE=\"$(VER_DATE)\"
|
-DVER_DATE=\"$(VER_DATE)\"
|
||||||
|
|
@ -159,8 +166,7 @@ release: releasedir
|
||||||
tar -czvf tuxpaint-$(VER_VERSION).tar.gz tuxpaint-$(VER_VERSION)
|
tar -czvf tuxpaint-$(VER_VERSION).tar.gz tuxpaint-$(VER_VERSION)
|
||||||
|
|
||||||
|
|
||||||
# "make nosound" builds the program with sound disabled, and man page,
|
# "make nosound" builds the program with sound disabled:
|
||||||
# from sources:
|
|
||||||
|
|
||||||
nosound:
|
nosound:
|
||||||
@echo
|
@echo
|
||||||
|
|
@ -169,6 +175,15 @@ nosound:
|
||||||
make SDL_MIXER_LIB= NOSOUNDFLAG=NOSOUND
|
make SDL_MIXER_LIB= NOSOUNDFLAG=NOSOUND
|
||||||
|
|
||||||
|
|
||||||
|
# "make nosvg" builds the program with SVG (Cairo) support disabled:
|
||||||
|
|
||||||
|
nosvg:
|
||||||
|
@echo
|
||||||
|
@echo "Building with SVG DISABLED"
|
||||||
|
@echo
|
||||||
|
make SVG_LIB= SVG_CFLAGS= NOSVGFLAG=NOSVG
|
||||||
|
|
||||||
|
|
||||||
# "make beos" builds the program for BeOS
|
# "make beos" builds the program for BeOS
|
||||||
|
|
||||||
beos:
|
beos:
|
||||||
|
|
@ -1034,6 +1049,7 @@ tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
|
||||||
$^ \
|
$^ \
|
||||||
$(HQXX_O) \
|
$(HQXX_O) \
|
||||||
$(SDL_LIBS) \
|
$(SDL_LIBS) \
|
||||||
|
$(SVG_LIB) \
|
||||||
-lm $(ARCH_LINKS)
|
-lm $(ARCH_LINKS)
|
||||||
@$(RSRC_CMD)
|
@$(RSRC_CMD)
|
||||||
@$(MIMESET_CMD)
|
@$(MIMESET_CMD)
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
Tux Paint
|
Tux Paint
|
||||||
version 0.9.16
|
version 0.9.17
|
||||||
Advanced Stamps HOWTO
|
Advanced Stamps HOWTO
|
||||||
|
|
||||||
Copyright 2006 by Albert Cahalan for the Tux Paint project
|
Copyright 2006 by Albert Cahalan for the Tux Paint project
|
||||||
New Breed Software
|
New Breed Software
|
||||||
|
|
||||||
albert@users.sf.net
|
albert@users.sf.net
|
||||||
http://www.newbreedsoftware .com/tuxpaint/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
March 8, 2006 - March 8, 2006
|
March 8, 2006 - October 26, 2006
|
||||||
|
|
||||||
About this HOWTO
|
About this HOWTO
|
||||||
|
|
||||||
This HOWTO assumes that you want to make an excellent Tux Paint stamp
|
This HOWTO assumes that you want to make an excellent Tux Paint stamp,
|
||||||
from a JPEG image. There are easier and faster methods that produce
|
in PNG bitmapped format, from a JPEG image (e.g., a digital photograph).
|
||||||
lower quality.
|
There are easier and faster methods that produce lower quality.
|
||||||
|
|
||||||
This HOWTO assumes you are dealing with normal opaque objects. Dealing
|
This HOWTO assumes you are dealing with normal opaque objects. Dealing
|
||||||
with semi-transparent objects (fire, moving fan blade, kid's baloon) or
|
with semi-transparent objects (fire, moving fan blade, kid's baloon) or
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,25 @@ http://www.newbreedsoftware.com/tuxpaint/
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
|
||||||
|
2006.October.26 (0.9.17)
|
||||||
|
|
||||||
|
* Tool Improvements:
|
||||||
|
------------------
|
||||||
|
* Stamps now supports SVG vector-based graphics! (Via Cairo library)
|
||||||
|
(Experimental; build with "make nosvg" to disable SVG support and
|
||||||
|
Cairo dependency.)
|
||||||
|
|
||||||
|
* Documentation Improvements:
|
||||||
|
---------------------------
|
||||||
|
* Discussed SVG Stamps in "Extending Tux Paint."
|
||||||
|
|
||||||
|
* Created an "SVG.txt" document, covering SVG software.
|
||||||
|
|
||||||
|
* Mentioned descriptive sounds (e.g., "stamp_desc_ll.ogg") in "Extending..."
|
||||||
|
|
||||||
|
* Listing new www.tuxpaint.org website URL.
|
||||||
|
|
||||||
|
|
||||||
2006.October.19 (0.9.16)
|
2006.October.19 (0.9.16)
|
||||||
|
|
||||||
* Interface improvements:
|
* Interface improvements:
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
Tux Paint
|
Tux Paint
|
||||||
version 0.9.16
|
version 0.9.17
|
||||||
Extending Tux Paint
|
Extending Tux Paint
|
||||||
|
|
||||||
Copyright 2002-2006 by Bill Kendrick and others
|
Copyright 2002-2006 by Bill Kendrick and others
|
||||||
New Breed Software
|
New Breed Software
|
||||||
|
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
June 14, 2002 - September 28, 2006
|
June 14, 2002 - October 26, 2006
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -217,28 +217,39 @@ Stamps
|
||||||
files. The one file that is required is, of course, the picture
|
files. The one file that is required is, of course, the picture
|
||||||
itself.
|
itself.
|
||||||
|
|
||||||
The Stamps used by Tux Paint are PNG pictures. They can be full-color
|
As of Tux Paint version 0.9.17, Stamps may be either PNG bitmap images
|
||||||
or greyscale. The alpha (transparency) of the PNG is used to determine
|
or SVG vector images. They can be full-color or greyscale. The alpha
|
||||||
the actual shape of the picture (otherwise you'll stamp a large
|
(transparency) channel of PNGs is used to determine the actual shape
|
||||||
rectangle on your drawings).
|
of the picture (otherwise you'll stamp a large rectangle on your
|
||||||
|
drawings).
|
||||||
|
|
||||||
The PNGs can be any size, but in practice, a 100 pixels wide by
|
PNGs can be any size, and Tux Paint (by default) provides a set of
|
||||||
100 pixels tall (100 x 100) is quite large for Tux Paint.
|
sizing buttons to let the user scale the stamp up (larger) and down
|
||||||
|
(smaller).
|
||||||
|
|
||||||
Note: If your new stamps all have solid rectangular-shaped outlines of
|
SVGs are vector-based, and will be scaled appropriately for the canvas
|
||||||
a solid color (e.g., white or black), it's because you forgot to use
|
being used in Tux Paint.
|
||||||
alpha transparency! See the documentation file "PNG.txt" for more
|
|
||||||
|
Note: If your new PNG stamps all have solid rectangular-shaped
|
||||||
|
outlines of a solid color (e.g., white or black), it's because you
|
||||||
|
forgot to use alpha transparency! See the documentation file "PNG.txt"
|
||||||
|
for more information and tips.
|
||||||
|
|
||||||
|
Note: If your new SVG stamps seem to have a lot of whitespace, make
|
||||||
|
sure the SVG 'document' is no larger than the shape(s) within. If they
|
||||||
|
are being clipped, make sure the 'document' is large enough to contain
|
||||||
|
the shape(s). See the documentation file "SVG.txt" for more
|
||||||
information and tips.
|
information and tips.
|
||||||
|
|
||||||
Advanced Users: The Advanced Stamps HOWTO describes, in detail, how to
|
Advanced Users: The Advanced Stamps HOWTO describes, in detail, how to
|
||||||
make images which will scale perfectly when used as stamps in
|
make PNG images which will scale perfectly when used as stamps in
|
||||||
Tux Paint.
|
Tux Paint.
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
Description Text
|
Description Text
|
||||||
|
|
||||||
Text (".TXT") files with the same name as the PNG. (e.g.,
|
Text (".TXT") files with the same name as the PNG or SVG. (e.g.,
|
||||||
"picture.png"'s description is stored in "picture.txt" in the same
|
"picture.png"'s description is stored in "picture.txt" in the same
|
||||||
directory.)
|
directory.)
|
||||||
|
|
||||||
|
|
@ -274,16 +285,16 @@ Stamps
|
||||||
|
|
||||||
Sound Effects
|
Sound Effects
|
||||||
|
|
||||||
WAVE (".WAV") files with the same name as the PNG. (e.g.,
|
WAVE (".wav") or OGG Vorbis (".ogg") files with the same name as the
|
||||||
"picture.png"'s sound effect is the sound "picture.wav" in the same
|
PNG or SVG. (e.g., "picture.svg"'s sound effect is the sound file
|
||||||
directory.)
|
"picture.wav" in the same directory.)
|
||||||
|
|
||||||
Language Support
|
Language Support
|
||||||
|
|
||||||
For sounds for different locales (e.g., if the sound is someone
|
For sounds for different locales (e.g., if the sound is someone
|
||||||
saying a word, and you want translated versions of the word said),
|
saying a word, and you want translated versions of the word said),
|
||||||
also create WAV files with the locale's label in the filename, in
|
also create WAV or OGG files with the locale's label in the
|
||||||
the form: "STAMP_LOCALE.wav"
|
filename, in the form: "STAMP_LOCALE.EXT"
|
||||||
|
|
||||||
"picture.png"'s sound effect, when Tux Paint is run in Spanish mode,
|
"picture.png"'s sound effect, when Tux Paint is run in Spanish mode,
|
||||||
would be "picture_es.wav". In French mode, "picture_fr.wav". And so
|
would be "picture_es.wav". In French mode, "picture_fr.wav". And so
|
||||||
|
|
@ -292,6 +303,31 @@ Stamps
|
||||||
If no localized sound effect can be loaded, Tux Paint will attempt
|
If no localized sound effect can be loaded, Tux Paint will attempt
|
||||||
to load the 'default' sound file. (e.g., "picture.wav")
|
to load the 'default' sound file. (e.g., "picture.wav")
|
||||||
|
|
||||||
|
Note: For descriptive sounds (not sound effects, like a bang or a bird
|
||||||
|
chirping), consider using the Descriptive Sounds, described below.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Descriptive Sound
|
||||||
|
|
||||||
|
WAVE (".wav") or OGG Vorbis (".ogg") files with the same name as the
|
||||||
|
PNG or SVG, followed by "_desc" (e.g., "picture.svg"'s descriptive
|
||||||
|
sound is the sound file "picture_desc.ogg" in the same directory.)
|
||||||
|
|
||||||
|
Language Support
|
||||||
|
|
||||||
|
For descriptions in different languages, also create WAV or OGG
|
||||||
|
files with both "_desc" and the locale's label in the filename, in
|
||||||
|
the form: "STAMP_desc_LOCALE.EXT"
|
||||||
|
|
||||||
|
"picture.png"'s descriptive sound, when Tux Paint is run in Spanish
|
||||||
|
mode, would be "picture_desc_es.wav". In French mode,
|
||||||
|
"picture_desc_fr.wav". And so on...
|
||||||
|
|
||||||
|
If no localized descriptive sound can be loaded, Tux Paint will
|
||||||
|
attempt to load the 'default' descriptive sound file. (e.g.,
|
||||||
|
"picture_desc.wav")
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
Stamp Options
|
Stamp Options
|
||||||
|
|
@ -302,9 +338,9 @@ Stamps
|
||||||
|
|
||||||
A stamp data file is simply a text file containing the options.
|
A stamp data file is simply a text file containing the options.
|
||||||
|
|
||||||
The file has the same name as the PNG image, but a ".dat" extension.
|
The file has the same name as the PNG or SVG image, but a ".dat"
|
||||||
(e.g., "picture.png"'s data file is the text file "picture.dat" in the
|
extension. (e.g., "picture.png"'s data file is the text file
|
||||||
same directory.)
|
"picture.dat" in the same directory.)
|
||||||
|
|
||||||
Colored Stamps
|
Colored Stamps
|
||||||
|
|
||||||
|
|
|
||||||
10
docs/FAQ.txt
10
docs/FAQ.txt
|
|
@ -1,14 +1,14 @@
|
||||||
Tux Paint
|
Tux Paint
|
||||||
version 0.9.16
|
version 0.9.17
|
||||||
Frequently Asked Questions
|
Frequently Asked Questions
|
||||||
|
|
||||||
Copyright 2002-2006 by Bill Kendrick and others
|
Copyright 2002-2006 by Bill Kendrick and others
|
||||||
New Breed Software
|
New Breed Software
|
||||||
|
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
September 14, 2002 - March 8, 2006
|
September 14, 2002 - October 26, 2006
|
||||||
|
|
||||||
Drawing-related
|
Drawing-related
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ Interface Problems
|
||||||
The appropriate fonts for such locales can be downloaded
|
The appropriate fonts for such locales can be downloaded
|
||||||
from the Tux Paint website:
|
from the Tux Paint website:
|
||||||
|
|
||||||
http://www.newbreedsoftware.com/tuxpaint/download/fonts/
|
http://www.tuxpaint,org/download/fonts/
|
||||||
|
|
||||||
Printing
|
Printing
|
||||||
|
|
||||||
|
|
@ -571,4 +571,4 @@ Help / Contact
|
||||||
|
|
||||||
Or post to our 'tuxpaint-users' mailing list:
|
Or post to our 'tuxpaint-users' mailing list:
|
||||||
|
|
||||||
http://www.newbreedsoftware.com/tuxpaint/lists/
|
http://www.tuxpaint.org/lists/
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ INSTALL.txt for Tux Paint
|
||||||
|
|
||||||
Tux Paint - A simple drawing program for children.
|
Tux Paint - A simple drawing program for children.
|
||||||
|
|
||||||
Copyright 2005 by Bill Kendrick and others
|
Copyright 2006 by Bill Kendrick and others
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
June 27, 2002 - February 26, 2005
|
June 27, 2002 -October 26, 2006
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -76,7 +76,14 @@ Requirements:
|
||||||
|
|
||||||
http://www.gnu.org/software/gettext/
|
http://www.gnu.org/software/gettext/
|
||||||
|
|
||||||
NetPBM Tools [OPTIONAL]
|
Cairo, libsvg, svg-cairo [EXPERIMENTAL] [can be disabled]
|
||||||
|
----------------------------------------
|
||||||
|
As of Tux Paint 0.9.17, SVG vector graphics are supported by the
|
||||||
|
'Stamps' tool.
|
||||||
|
|
||||||
|
http://www.cairographics.org/
|
||||||
|
|
||||||
|
NetPBM Tools [OPTIONAL] [No longer used, by default]
|
||||||
------------------------
|
------------------------
|
||||||
Under Linux and Unix, the NetPBM tools are what are currently
|
Under Linux and Unix, the NetPBM tools are what are currently
|
||||||
used for printing. (A PNG is generated by TuxPaint, and converted
|
used for printing. (A PNG is generated by TuxPaint, and converted
|
||||||
|
|
@ -183,6 +190,15 @@ Compiling and Installation:
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
|
Disabling SVG support (and hence Cairo, libSVG and svg-cairo dependencies):
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
To disable SVG support (e.g., if your system is not currently supported
|
||||||
|
by the Cairo library or other SVG-related dependencies), you can
|
||||||
|
run "make" with "nosvg" as the 'target', instead:
|
||||||
|
|
||||||
|
$ make nosvg
|
||||||
|
|
||||||
|
|
||||||
Disabling Sound at Compile-time:
|
Disabling Sound at Compile-time:
|
||||||
--------------------------------
|
--------------------------------
|
||||||
Alternatively, if you don't have a sound card, or would prefer to build
|
Alternatively, if you don't have a sound card, or would prefer to build
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Tux Paint
|
Tux Paint
|
||||||
version 0.9.16
|
version 0.9.17
|
||||||
|
|
||||||
Options Documentation
|
Options Documentation
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
New Breed Software
|
New Breed Software
|
||||||
|
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
October 11, 2006
|
October 26, 2006
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -899,8 +899,8 @@ Setting Your Environment's Locale
|
||||||
/usr/share/tuxpaint/fonts/locale/ko.ttf
|
/usr/share/tuxpaint/fonts/locale/ko.ttf
|
||||||
|
|
||||||
You can download fonts for supported languages from Tux Paint's
|
You can download fonts for supported languages from Tux Paint's
|
||||||
website, http://www.newbreedsoftware.com/tuxpaint/. (Look in the
|
website, http://www.tuxpaint.org/. (Look in the 'Fonts' section under
|
||||||
'Fonts' section under 'Download.')
|
'Download.')
|
||||||
|
|
||||||
Under Unix and Linux, you can use the Makefile that comes with the
|
Under Unix and Linux, you can use the Makefile that comes with the
|
||||||
font to install the font in the appropriate location.
|
font to install the font in the appropriate location.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Tux Paint
|
Tux Paint
|
||||||
version 0.9.16
|
version 0.9.17
|
||||||
|
|
||||||
A simple drawing program for children
|
A simple drawing program for children
|
||||||
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
New Breed Software
|
New Breed Software
|
||||||
|
|
||||||
bill@newbreedsoftware.com
|
bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
June 14, 2002 - September 9, 2006
|
June 14, 2002 - October 26, 2006
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -785,7 +785,9 @@ Doing it Manually
|
||||||
Detailed instructions on command-line and configuration-file
|
Detailed instructions on command-line and configuration-file
|
||||||
options, for those who don't want to use Tux Paint Config.
|
options, for those who don't want to use Tux Paint Config.
|
||||||
* PNG.txt
|
* PNG.txt
|
||||||
Notes on creating PNG format images for use in Tux Paint
|
Notes on creating PNG format bitmapped images for use in Tux Paint
|
||||||
|
* SVG.txt
|
||||||
|
Notes on creating SVG format vector images for use in Tux Paint
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -798,4 +800,4 @@ Doing it Manually
|
||||||
You may also wish to participate in the numerous Tux Paint mailing
|
You may also wish to participate in the numerous Tux Paint mailing
|
||||||
lists:
|
lists:
|
||||||
|
|
||||||
http://www.newbreedsoftware.com/tuxpaint/lists/
|
http://www.tuxpaint.org/lists/
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ alink="#FF00FF">
|
||||||
alt="Tux Paint"><br>
|
alt="Tux Paint"><br>
|
||||||
version
|
version
|
||||||
|
|
||||||
0.9.16
|
0.9.17
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
Advanced Stamps HOWTO</h1>
|
Advanced Stamps HOWTO</h1>
|
||||||
|
|
@ -19,10 +19,9 @@ Advanced Stamps HOWTO</h1>
|
||||||
<p>Copyright 2006 by Albert Cahalan for the Tux Paint project<br>
|
<p>Copyright 2006 by Albert Cahalan for the Tux Paint project<br>
|
||||||
New Breed Software</p>
|
New Breed Software</p>
|
||||||
<p><a href="mailto:albert@users.sf.net">albert@users.sf.net</a><br>
|
<p><a href="mailto:albert@users.sf.net">albert@users.sf.net</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware
|
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||||
.com/tuxpaint/</a></p>
|
|
||||||
|
|
||||||
<p>March 8, 2006 - March 8, 2006</p>
|
<p>March 8, 2006 - October 26, 2006</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,7 +29,8 @@ New Breed Software</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
|
|
||||||
<p>This HOWTO assumes that you want to make an excellent Tux Paint
|
<p>This HOWTO assumes that you want to make an excellent Tux Paint
|
||||||
stamp from a JPEG image. There are easier and faster methods that
|
stamp, in PNG bitmapped format, from a JPEG image (e.g., a digital
|
||||||
|
photograph). There are easier and faster methods that
|
||||||
produce lower quality.</p>
|
produce lower quality.</p>
|
||||||
|
|
||||||
<p>This HOWTO assumes you are dealing with normal opaque objects. Dealing
|
<p>This HOWTO assumes you are dealing with normal opaque objects. Dealing
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ alt="Tux Paint"><br>
|
||||||
|
|
||||||
version
|
version
|
||||||
|
|
||||||
0.9.16
|
0.9.17
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
Extending Tux Paint</h1>
|
Extending Tux Paint</h1>
|
||||||
|
|
@ -21,9 +21,9 @@ Extending Tux Paint</h1>
|
||||||
New Breed Software</p>
|
New Breed Software</p>
|
||||||
|
|
||||||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||||
|
|
||||||
<p>June 14, 2002 - September 28, 2006</p>
|
<p>June 14, 2002 - October 26, 2006</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<hr size=2 noshade>
|
<hr size=2 noshade>
|
||||||
|
|
@ -307,23 +307,34 @@ effect.</p>
|
||||||
|
|
||||||
<img src="images/stamp_edit.png" width=128 height=147 alt="" align=right>
|
<img src="images/stamp_edit.png" width=128 height=147 alt="" align=right>
|
||||||
|
|
||||||
<p>The Stamps used by Tux Paint are PNG pictures. They can be
|
<p>As of Tux Paint version 0.9.17, Stamps may be either PNG
|
||||||
full-color or greyscale. The alpha (transparency) of the PNG is
|
bitmap images or SVG vector images. They can be full-color or greyscale.
|
||||||
used to determine the actual shape of the picture (otherwise you'll
|
The alpha (transparency) channel of PNGs is used to determine the actual
|
||||||
stamp a large rectangle on your drawings).</p>
|
shape of the picture (otherwise you'll stamp a large rectangle on your
|
||||||
|
drawings).</p>
|
||||||
|
|
||||||
<p>The PNGs can be any size, but in practice, a 100 pixels wide by
|
<p>PNGs can be any size, and Tux Paint (by default) provides
|
||||||
100 pixels tall (100 x 100) is quite large for
|
a set of sizing buttons to let the user scale the stamp up (larger)
|
||||||
Tux Paint.</p>
|
and down (smaller).</p>
|
||||||
|
|
||||||
<p>Note: If your new stamps all have solid rectangular-shaped outlines
|
<p>SVGs are vector-based, and will be scaled appropriately for the
|
||||||
|
canvas being used in Tux Paint.</p>
|
||||||
|
|
||||||
|
<p>Note: If your new PNG stamps all have solid rectangular-shaped outlines
|
||||||
of a solid color (e.g., white or black), it's because you forgot to use
|
of a solid color (e.g., white or black), it's because you forgot to use
|
||||||
alpha transparency! See the documentation file
|
alpha transparency! See the documentation file
|
||||||
"<a href="../PNG.txt">PNG.txt</a>" for more information and tips.</p>
|
"<a href="../PNG.txt">PNG.txt</a>" for more information and tips.</p>
|
||||||
|
|
||||||
<p><b>Advanced Users:</b> The <a href="ADVANCED-STAMPS-HOWTO.html">Advanced
|
<p>Note: If your new SVG stamps seem to have a lot of whitespace,
|
||||||
Stamps HOWTO</a> describes, in detail, how to make images which will
|
make sure the SVG 'document' is no larger than the shape(s) within.
|
||||||
scale perfectly when used as stamps in Tux Paint.</p>
|
If they are being clipped, make sure the 'document' is large enough
|
||||||
|
to contain the shape(s). See the documentation file
|
||||||
|
"<a href="../SVG.txt">SVG.txt</a>" for more information and tips.</p>
|
||||||
|
|
||||||
|
<p><b>Advanced Users:</b> The
|
||||||
|
<a href="ADVANCED-STAMPS-HOWTO.html">Advanced Stamps HOWTO</a> describes,
|
||||||
|
in detail, how to make PNG images which will scale perfectly when used as
|
||||||
|
stamps in Tux Paint.</p>
|
||||||
|
|
||||||
<br clear=all>
|
<br clear=all>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
@ -332,7 +343,7 @@ effect.</p>
|
||||||
|
|
||||||
<h3>Description Text</h3>
|
<h3>Description Text</h3>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>Text (".TXT") files with the same name as the PNG.
|
<p>Text (".TXT") files with the same name as the PNG or SVG.
|
||||||
(e.g., "<code>picture.png</code>"'s description is stored in
|
(e.g., "<code>picture.png</code>"'s description is stored in
|
||||||
"<code>picture.txt</code>" in the same directory.)</p>
|
"<code>picture.txt</code>" in the same directory.)</p>
|
||||||
|
|
||||||
|
|
@ -372,17 +383,18 @@ effect.</p>
|
||||||
|
|
||||||
<h3>Sound Effects</h3>
|
<h3>Sound Effects</h3>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>WAVE (".WAV") files with the same name as the PNG.
|
<p>WAVE (".wav") or OGG Vorbis (".ogg")
|
||||||
(e.g., "<code>picture.png</code>"'s sound effect is the sound
|
files with the same name as the PNG or SVG.
|
||||||
|
(e.g., "<code>picture.svg</code>"'s sound effect is the sound file
|
||||||
"<code>picture.wav</code>" in the same directory.)</p>
|
"<code>picture.wav</code>" in the same directory.)</p>
|
||||||
|
|
||||||
<h4>Language Support</h4>
|
<h4>Language Support</h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>For sounds for different locales (e.g., if the sound is someone
|
<p>For sounds for different locales (e.g., if the sound is someone
|
||||||
saying a word, and you want translated versions of the word said),
|
saying a word, and you want translated versions of the word said),
|
||||||
also create WAV files with the locale's label in the filename, in
|
also create WAV or OGG files with the locale's label in the filename, in
|
||||||
the form: "<code><b>STAMP_LOCALE</b>.wav</code>"</p>
|
the form: "<code><b>STAMP_LOCALE.EXT</b></code>"</p>
|
||||||
|
|
||||||
<p>"<code>picture.png</code>"'s sound effect, when Tux Paint is run
|
<p>"<code>picture.png</code>"'s sound effect, when Tux Paint is run
|
||||||
in Spanish mode, would be "<code>picture_es.wav</code>".
|
in Spanish mode, would be "<code>picture_es.wav</code>".
|
||||||
In French mode, "<code>picture_fr.wav</code>". And so on...</p>
|
In French mode, "<code>picture_fr.wav</code>". And so on...</p>
|
||||||
|
|
@ -391,6 +403,37 @@ effect.</p>
|
||||||
attempt to load the 'default' sound file.
|
attempt to load the 'default' sound file.
|
||||||
(e.g., "<code>picture.wav</code>")</p>
|
(e.g., "<code>picture.wav</code>")</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
|
<p>Note: For descriptive sounds (not sound effects, like a bang or
|
||||||
|
a bird chirping), consider using the Descriptive Sounds,
|
||||||
|
described below.</p>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<hr size=1 noshade>
|
||||||
|
|
||||||
|
<h3>Descriptive Sound</h3>
|
||||||
|
<blockquote>
|
||||||
|
<p>WAVE (".wav") or OGG Vorbis (".ogg")
|
||||||
|
files with the same name as the PNG or SVG, followed by
|
||||||
|
"<code>_desc</code>" (e.g., "<code>picture.svg</code>"'s descriptive
|
||||||
|
sound is the sound file "<code>picture_desc.ogg</code>" in the same
|
||||||
|
directory.)</p>
|
||||||
|
|
||||||
|
<h4>Language Support</h4>
|
||||||
|
<blockquote>
|
||||||
|
<p>For descriptions in different languages,
|
||||||
|
also create WAV or OGG files with both "<code>_desc</code>" and
|
||||||
|
the locale's label in the filename, in
|
||||||
|
the form: "<code><b>STAMP_desc_LOCALE.EXT</b></code>"</p>
|
||||||
|
|
||||||
|
<p>"<code>picture.png</code>"'s descriptive sound, when Tux Paint
|
||||||
|
is run in Spanish mode, would be "<code>picture_desc_es.wav</code>".
|
||||||
|
In French mode, "<code>picture_desc_fr.wav</code>". And so on...</p>
|
||||||
|
|
||||||
|
<p>If no localized descriptive sound can be loaded, Tux Paint will
|
||||||
|
attempt to load the 'default' descriptive sound file.
|
||||||
|
(e.g., "<code>picture_desc.wav</code>")</p>
|
||||||
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<hr size=1 noshade>
|
<hr size=1 noshade>
|
||||||
|
|
@ -403,9 +446,10 @@ effect.</p>
|
||||||
|
|
||||||
<p>A stamp data file is simply a text file containing the options.</p>
|
<p>A stamp data file is simply a text file containing the options.</p>
|
||||||
|
|
||||||
<p>The file has the same name as the PNG image, but a "<code>.dat</code>"
|
<p>The file has the same name as the PNG or SVG image, but a
|
||||||
extension. (e.g., "<code>picture.png</code>"'s data file is the text
|
"<code>.dat</code>" extension. (e.g., "<code>picture.png</code>"'s
|
||||||
file "<code>picture.dat</code>" in the same directory.)</p>
|
data file is the text file "<code>picture.dat</code>" in the same
|
||||||
|
directory.)</p>
|
||||||
|
|
||||||
<h4>Colored Stamps</h4>
|
<h4>Colored Stamps</h4>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ alink="#FF00FF">
|
||||||
alt="Tux Paint"><br>
|
alt="Tux Paint"><br>
|
||||||
version
|
version
|
||||||
|
|
||||||
0.9.16
|
0.9.17
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
Frequently Asked Questions</h1>
|
Frequently Asked Questions</h1>
|
||||||
|
|
@ -20,9 +20,9 @@ Frequently Asked Questions</h1>
|
||||||
New Breed Software</p>
|
New Breed Software</p>
|
||||||
|
|
||||||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||||
|
|
||||||
<p>September 14, 2002 - March 8, 2006</p>
|
<p>September 14, 2002 - October 26, 2006</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<h2>Drawing-related</h2>
|
<h2>Drawing-related</h2>
|
||||||
|
|
@ -197,8 +197,8 @@ New Breed Software</p>
|
||||||
Tux Paint website:</p>
|
Tux Paint website:</p>
|
||||||
|
|
||||||
<blockquote><p>
|
<blockquote><p>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/download/fonts/"
|
<a href="http://www.tuxpaint.org/download/fonts/"
|
||||||
>http://www.newbreedsoftware.com/tuxpaint/download/fonts/</a>
|
>http://www.tuxpaint,org/download/fonts/</a>
|
||||||
</p></blockquote>
|
</p></blockquote>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -648,8 +648,7 @@ New Breed Software</p>
|
||||||
|
|
||||||
<p>Or post to our 'tuxpaint-users' mailing list:</p>
|
<p>Or post to our 'tuxpaint-users' mailing list:</p>
|
||||||
|
|
||||||
<blockquote><p><a href="http://www.newbreedsoftware.com/tuxpaint/lists/"
|
<blockquote><p><a href="http://www.tuxpaint.org/lists/">http://www.tuxpaint.org/lists/</a></p></blockquote>
|
||||||
>http://www.newbreedsoftware.com/tuxpaint/lists/</a></p></blockquote>
|
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ alink="#FF00FF">
|
||||||
|
|
||||||
version
|
version
|
||||||
|
|
||||||
0.9.16
|
0.9.17
|
||||||
|
|
||||||
</h1>
|
</h1>
|
||||||
<h2>Options Documentation</h2>
|
<h2>Options Documentation</h2>
|
||||||
|
|
@ -20,9 +20,9 @@ version
|
||||||
New Breed Software</p>
|
New Breed Software</p>
|
||||||
|
|
||||||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||||
|
|
||||||
<p>October 11, 2006</p>
|
<p>October 26, 2006</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<hr size=2 noshade>
|
<hr size=2 noshade>
|
||||||
|
|
@ -1477,8 +1477,7 @@ New Breed Software</p>
|
||||||
|
|
||||||
You can download fonts for supported languages from Tux Paint's
|
You can download fonts for supported languages from Tux Paint's
|
||||||
website,
|
website,
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">
|
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a>.
|
||||||
http://www.newbreedsoftware.com/tuxpaint/</a>.
|
|
||||||
(Look in the 'Fonts' section under 'Download.')<p>
|
(Look in the 'Fonts' section under 'Download.')<p>
|
||||||
|
|
||||||
Under Unix and Linux, you can use the <code>Makefile</code> that comes
|
Under Unix and Linux, you can use the <code>Makefile</code> that comes
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ alt="Tux Paint"><br>
|
||||||
|
|
||||||
version
|
version
|
||||||
|
|
||||||
0.9.16
|
0.9.17
|
||||||
|
|
||||||
</h1>
|
</h1>
|
||||||
<h3>A simple drawing program for children</h3>
|
<h3>A simple drawing program for children</h3>
|
||||||
|
|
@ -21,9 +21,9 @@ version
|
||||||
New Breed Software</p>
|
New Breed Software</p>
|
||||||
|
|
||||||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||||
|
|
||||||
<p>June 14, 2002 - September 9, 2006</p>
|
<p>June 14, 2002 - October 26, 2006</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<hr size=2 noshade>
|
<hr size=2 noshade>
|
||||||
|
|
@ -1005,8 +1005,9 @@ New Breed Software</p>
|
||||||
manually.</p>
|
manually.</p>
|
||||||
|
|
||||||
<p>Load a graphics program that is capable of both loading your picture
|
<p>Load a graphics program that is capable of both loading your picture
|
||||||
and saving a PNG format file. (See the documentation file "PNG.txt"
|
and saving a PNG format file. (See the documentation file
|
||||||
for a list of suggested software, and other references.)</p>
|
"<a href="../PNG.txt">PNG.txt</a>" for a list of suggested software,
|
||||||
|
and other references.)</p>
|
||||||
|
|
||||||
<p>Reduce the size of the image to no wider than 448 pixels across and
|
<p>Reduce the size of the image to no wider than 448 pixels across and
|
||||||
no taller than 376 pixels tall. (i.e., the maximum size
|
no taller than 376 pixels tall. (i.e., the maximum size
|
||||||
|
|
@ -1070,7 +1071,10 @@ New Breed Software</p>
|
||||||
for those who don't want to use Tux Paint Config.
|
for those who don't want to use Tux Paint Config.
|
||||||
|
|
||||||
<li><a href="../PNG.txt">PNG.txt</a><br>
|
<li><a href="../PNG.txt">PNG.txt</a><br>
|
||||||
Notes on creating PNG format images for use in Tux Paint
|
Notes on creating PNG format bitmapped images for use in Tux Paint
|
||||||
|
|
||||||
|
<li><a href="../SVG.txt">SVG.txt</a><br>
|
||||||
|
Notes on creating SVG format vector images for use in Tux Paint
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
@ -1090,7 +1094,7 @@ New Breed Software</p>
|
||||||
lists:</p>
|
lists:</p>
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/lists/">http://www.newbreedsoftware.com/tuxpaint/lists/</a>
|
<a href="http://www.tuxpaint.org/lists/">http://www.tuxpaint.org/lists/</a>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
|
||||||
405
src/tuxpaint.c
405
src/tuxpaint.c
|
|
@ -22,7 +22,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
June 14, 2002 - October 9, 2006
|
June 14, 2002 - October 26, 2006
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -116,6 +116,9 @@ static unsigned draw_colors(unsigned action);
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// hide all scale-related values here
|
// hide all scale-related values here
|
||||||
|
|
||||||
|
// FIXME: Does this take into account taller-than-wide canvas sizes?
|
||||||
|
// (e.g., 768x1024 on a tablet PC in 'portrait' configuration?)
|
||||||
|
// -bjk 2006.10.26
|
||||||
typedef struct scaleparams
|
typedef struct scaleparams
|
||||||
{
|
{
|
||||||
unsigned numer, denom;
|
unsigned numer, denom;
|
||||||
|
|
@ -335,6 +338,19 @@ typedef struct safer_dirent
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
#include "cairo.h"
|
||||||
|
#include "svg.h"
|
||||||
|
#include "svg-cairo.h"
|
||||||
|
#if !defined(CAIRO_H) || !defined(SVG_H) || !defined(SVG_CAIRO_H)
|
||||||
|
#error "---------------------------------------------------"
|
||||||
|
#error "If you installed Cairo, libSVG or svg-cairo from packages, be sure"
|
||||||
|
#error "to get the development package, as well!"
|
||||||
|
#error "(e.g., 'libcairo2-dev.rpm')"
|
||||||
|
#error "---------------------------------------------------"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SAVE_AS_BMP
|
#ifndef SAVE_AS_BMP
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#define FNAME_EXTENSION ".png"
|
#define FNAME_EXTENSION ".png"
|
||||||
|
|
@ -958,7 +974,7 @@ static int stamp_tintable(int stamp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SHAPE_BRUSH_NAME "round_03.png"
|
#define SHAPE_BRUSH_NAME "aa_round_03.png"
|
||||||
static int num_brushes, num_brushes_max, shape_brush = 0;
|
static int num_brushes, num_brushes_max, shape_brush = 0;
|
||||||
static SDL_Surface **img_brushes;
|
static SDL_Surface **img_brushes;
|
||||||
static int * brushes_frames = NULL;
|
static int * brushes_frames = NULL;
|
||||||
|
|
@ -1224,6 +1240,15 @@ static char *debug_gettext(const char *str);
|
||||||
static int charsize(char c);
|
static int charsize(char c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
SDL_Surface * load_svg(char * file);
|
||||||
|
SDL_Surface * myIMG_Load(char * file);
|
||||||
|
float pick_best_scape(unsigned int orig_w, unsigned int orig_h,
|
||||||
|
unsigned int max_w, unsigned int max_h);
|
||||||
|
#else
|
||||||
|
#define myIMG_Load IMG_Load
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define MAX_UTF8_CHAR_LENGTH 6
|
#define MAX_UTF8_CHAR_LENGTH 6
|
||||||
|
|
||||||
|
|
@ -5496,7 +5521,7 @@ static void set_active_stamp(void)
|
||||||
{
|
{
|
||||||
stamp_type *sd = stamp_data[cur_stamp];
|
stamp_type *sd = stamp_data[cur_stamp];
|
||||||
unsigned len = strlen(sd->stampname);
|
unsigned len = strlen(sd->stampname);
|
||||||
char *buf = alloca(len + strlen("_mirror.png") + 1);
|
char *buf = alloca(len + strlen("_mirror.EXT") + 1);
|
||||||
|
|
||||||
if (active_stamp)
|
if (active_stamp)
|
||||||
SDL_FreeSurface(active_stamp);
|
SDL_FreeSurface(active_stamp);
|
||||||
|
|
@ -5508,11 +5533,29 @@ static void set_active_stamp(void)
|
||||||
{
|
{
|
||||||
memcpy(buf + len, "_mirror.png", 12);
|
memcpy(buf + len, "_mirror.png", 12);
|
||||||
active_stamp = do_loadimage(buf, 0);
|
active_stamp = do_loadimage(buf, 0);
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (active_stamp == NULL)
|
||||||
|
{
|
||||||
|
memcpy(buf + len, "_mirror.svg", 12);
|
||||||
|
active_stamp = do_loadimage(buf, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!active_stamp)
|
if (!active_stamp)
|
||||||
{
|
{
|
||||||
memcpy(buf + len, ".png", 5);
|
memcpy(buf + len, ".png", 5);
|
||||||
active_stamp = do_loadimage(buf, 0);
|
active_stamp = do_loadimage(buf, 0);
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (active_stamp == NULL)
|
||||||
|
{
|
||||||
|
memcpy(buf + len, ".svg", 5);
|
||||||
|
active_stamp = do_loadimage(buf, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!active_stamp)
|
if (!active_stamp)
|
||||||
active_stamp = thumbnail(img_dead40x40, 40, 40, 1); // copy it
|
active_stamp = thumbnail(img_dead40x40, 40, 40, 1); // copy it
|
||||||
if (sd->mirrored)
|
if (sd->mirrored)
|
||||||
|
|
@ -5527,7 +5570,7 @@ static void get_stamp_thumb(stamp_type * sd)
|
||||||
{
|
{
|
||||||
SDL_Surface *bigimg = NULL;
|
SDL_Surface *bigimg = NULL;
|
||||||
unsigned len = strlen(sd->stampname);
|
unsigned len = strlen(sd->stampname);
|
||||||
char *buf = alloca(len + strlen("_mirror.png") + 1);
|
char *buf = alloca(len + strlen("_mirror.EXT") + 1);
|
||||||
SDL_Surface *wrongmirror = NULL;
|
SDL_Surface *wrongmirror = NULL;
|
||||||
int need_mirror = 0;
|
int need_mirror = 0;
|
||||||
double ratio;
|
double ratio;
|
||||||
|
|
@ -5591,6 +5634,15 @@ static void get_stamp_thumb(stamp_type * sd)
|
||||||
{
|
{
|
||||||
memcpy(buf + len, "_mirror.png", 12);
|
memcpy(buf + len, "_mirror.png", 12);
|
||||||
bigimg = do_loadimage(buf, 0);
|
bigimg = do_loadimage(buf, 0);
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (bigimg == NULL)
|
||||||
|
{
|
||||||
|
memcpy(buf + len, "_mirror.svg", 12);
|
||||||
|
bigimg = do_loadimage(buf, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bigimg)
|
if (bigimg)
|
||||||
{
|
{
|
||||||
if (wrongmirror)
|
if (wrongmirror)
|
||||||
|
|
@ -5615,6 +5667,15 @@ static void get_stamp_thumb(stamp_type * sd)
|
||||||
{
|
{
|
||||||
memcpy(buf + len, ".png", 5);
|
memcpy(buf + len, ".png", 5);
|
||||||
bigimg = do_loadimage(buf, 0);
|
bigimg = do_loadimage(buf, 0);
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (bigimg == NULL)
|
||||||
|
{
|
||||||
|
memcpy(buf + len, ".svg", 5);
|
||||||
|
bigimg = do_loadimage(buf, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sd->mirrored)
|
if (sd->mirrored)
|
||||||
need_mirror = 1; // want to mirror after scaling
|
need_mirror = 1; // want to mirror after scaling
|
||||||
}
|
}
|
||||||
|
|
@ -5661,13 +5722,26 @@ static void loadstamp_callback(SDL_Surface * screen,
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
char fname[512];
|
char fname[512];
|
||||||
char *dotpng = (char *) strcasestr(files[i].str, ".png");
|
const char *dotext, *ext, *mirror_ext;
|
||||||
|
|
||||||
|
ext = ".png";
|
||||||
|
mirror_ext = "_mirror.png";
|
||||||
|
dotext = (char *) strcasestr(files[i].str, ext);
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (dotext == NULL)
|
||||||
|
{
|
||||||
|
ext = ".svg";
|
||||||
|
mirror_ext = "_mirror.svg";
|
||||||
|
dotext = (char *) strcasestr(files[i].str, ext);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
show_progress_bar(screen);
|
show_progress_bar(screen);
|
||||||
|
|
||||||
if (dotpng > files[i].str && !strcasecmp(dotpng, ".png")
|
if (dotext > files[i].str && !strcasecmp(dotext, ext)
|
||||||
&& (dotpng - files[i].str + 1 + dirlen < sizeof fname)
|
&& (dotext - files[i].str + 1 + dirlen < sizeof fname)
|
||||||
&& !strcasestr(files[i].str, "_mirror.png"))
|
&& !strcasestr(files[i].str, mirror_ext))
|
||||||
{
|
{
|
||||||
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
|
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
|
||||||
if (num_stamps == max_stamps)
|
if (num_stamps == max_stamps)
|
||||||
|
|
@ -5677,10 +5751,10 @@ static void loadstamp_callback(SDL_Surface * screen,
|
||||||
}
|
}
|
||||||
stamp_data[num_stamps] = calloc(1, sizeof *stamp_data[num_stamps]);
|
stamp_data[num_stamps] = calloc(1, sizeof *stamp_data[num_stamps]);
|
||||||
stamp_data[num_stamps]->stampname =
|
stamp_data[num_stamps]->stampname =
|
||||||
malloc(dotpng - files[i].str + 1 + dirlen + 1);
|
malloc(dotext - files[i].str + 1 + dirlen + 1);
|
||||||
memcpy(stamp_data[num_stamps]->stampname, fname,
|
memcpy(stamp_data[num_stamps]->stampname, fname,
|
||||||
dotpng - files[i].str + 1 + dirlen);
|
dotext - files[i].str + 1 + dirlen);
|
||||||
stamp_data[num_stamps]->stampname[dotpng - files[i].str + 1 + dirlen] =
|
stamp_data[num_stamps]->stampname[dotext - files[i].str + 1 + dirlen] =
|
||||||
'\0';
|
'\0';
|
||||||
num_stamps++;
|
num_stamps++;
|
||||||
}
|
}
|
||||||
|
|
@ -7419,7 +7493,7 @@ static SDL_Surface *do_loadimage(const char *const fname, int abort_on_error)
|
||||||
|
|
||||||
/* Load the image file: */
|
/* Load the image file: */
|
||||||
|
|
||||||
s = IMG_Load(fname);
|
s = myIMG_Load(fname);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
{
|
{
|
||||||
if (abort_on_error)
|
if (abort_on_error)
|
||||||
|
|
@ -9784,7 +9858,7 @@ static void strip_trailing_whitespace(char *buf)
|
||||||
|
|
||||||
static char *loaddesc(const char *const fname, Uint8 * locale_text)
|
static char *loaddesc(const char *const fname, Uint8 * locale_text)
|
||||||
{
|
{
|
||||||
char *txt_fname;
|
char *txt_fname, *extptr;
|
||||||
char buf[256], def_buf[256];
|
char buf[256], def_buf[256];
|
||||||
int found, got_first;
|
int found, got_first;
|
||||||
FILE *fi;
|
FILE *fi;
|
||||||
|
|
@ -9793,9 +9867,16 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text)
|
||||||
txt_fname = strdup(fname);
|
txt_fname = strdup(fname);
|
||||||
*locale_text = 0;
|
*locale_text = 0;
|
||||||
|
|
||||||
if (strcasestr(txt_fname, ".png") != NULL) // FIXME: isn't this always OK?
|
extptr = strcasestr(txt_fname, ".png");
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (extptr == NULL)
|
||||||
|
extptr = strcasestr(txt_fname, ".svg");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (extptr != NULL)
|
||||||
{
|
{
|
||||||
strcpy((char *) strcasestr(txt_fname, ".png"), ".txt");
|
strcpy((char *) extptr, ".txt");
|
||||||
|
|
||||||
fi = fopen(txt_fname, "r");
|
fi = fopen(txt_fname, "r");
|
||||||
free(txt_fname);
|
free(txt_fname);
|
||||||
|
|
@ -10173,6 +10254,16 @@ static void load_starter(char *img_id)
|
||||||
snprintf(fname, sizeof(fname), "%s/%s.png", dirname, img_id);
|
snprintf(fname, sizeof(fname), "%s/%s.png", dirname, img_id);
|
||||||
tmp_surf = IMG_Load(fname);
|
tmp_surf = IMG_Load(fname);
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (tmp_surf == NULL)
|
||||||
|
{
|
||||||
|
/* Try loading an SVG */
|
||||||
|
|
||||||
|
snprintf(fname, sizeof(fname), "%s/%s.svg", dirname, img_id);
|
||||||
|
tmp_surf = load_svg(fname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tmp_surf != NULL)
|
if (tmp_surf != NULL)
|
||||||
{
|
{
|
||||||
img_starter = SDL_DisplayFormatAlpha(tmp_surf);
|
img_starter = SDL_DisplayFormatAlpha(tmp_surf);
|
||||||
|
|
@ -10211,6 +10302,15 @@ static void load_starter(char *img_id)
|
||||||
tmp_surf = IMG_Load(fname);
|
tmp_surf = IMG_Load(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
/* (Failed? Try SVG next) */
|
||||||
|
if (tmp_surf == NULL)
|
||||||
|
{
|
||||||
|
snprintf(fname, sizeof(fname), "%s/%s-back.svg", dirname, img_id);
|
||||||
|
tmp_surf = load_svg(fname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tmp_surf != NULL)
|
if (tmp_surf != NULL)
|
||||||
{
|
{
|
||||||
img_starter_bkgd = SDL_DisplayFormat(tmp_surf);
|
img_starter_bkgd = SDL_DisplayFormat(tmp_surf);
|
||||||
|
|
@ -12152,6 +12252,17 @@ void do_open(void)
|
||||||
|
|
||||||
img = IMG_Load(fname);
|
img = IMG_Load(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
if (img == NULL)
|
||||||
|
{
|
||||||
|
/* (Try SVG next) */
|
||||||
|
snprintf(fname, sizeof(fname), "%s/%s-back.svg",
|
||||||
|
dirname[d_places[num_files]], d_names[num_files]);
|
||||||
|
|
||||||
|
img = load_svg(fname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12166,7 +12277,7 @@ void do_open(void)
|
||||||
#ifdef SAVE_AS_BMP
|
#ifdef SAVE_AS_BMP
|
||||||
img = SDL_LoadBMP(fname);
|
img = SDL_LoadBMP(fname);
|
||||||
#else
|
#else
|
||||||
img = IMG_Load(fname);
|
img = myIMG_Load(fname);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12885,7 +12996,7 @@ void do_open(void)
|
||||||
#ifdef SAVE_AS_BMP
|
#ifdef SAVE_AS_BMP
|
||||||
img = SDL_LoadBMP(fname);
|
img = SDL_LoadBMP(fname);
|
||||||
#else
|
#else
|
||||||
img = IMG_Load(fname);
|
img = myIMG_Load(fname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (img == NULL)
|
if (img == NULL)
|
||||||
|
|
@ -13226,7 +13337,7 @@ int do_slideshow(void)
|
||||||
#ifdef SAVE_AS_BMP
|
#ifdef SAVE_AS_BMP
|
||||||
img = SDL_LoadBMP(fname);
|
img = SDL_LoadBMP(fname);
|
||||||
#else
|
#else
|
||||||
img = IMG_Load(fname);
|
img = myIMG_Load(fname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13818,7 +13929,7 @@ void play_slideshow(int * selected, int num_selected, char * dirname,
|
||||||
#ifdef SAVE_AS_BMP
|
#ifdef SAVE_AS_BMP
|
||||||
img = SDL_LoadBMP(fname);
|
img = SDL_LoadBMP(fname);
|
||||||
#else
|
#else
|
||||||
img = IMG_Load(fname);
|
img = myIMG_Load(fname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (img != NULL)
|
if (img != NULL)
|
||||||
|
|
@ -15455,3 +15566,259 @@ int paintsound(int size)
|
||||||
else
|
else
|
||||||
return(SND_PAINT1 + (size / 12));
|
return(SND_PAINT1 + (size / 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NOSVG
|
||||||
|
// Based on cairo-demo/sdl/main.c from Cairo (GPL'd, (c) 2004 Eric Windisch):
|
||||||
|
SDL_Surface * load_svg(char * file)
|
||||||
|
{
|
||||||
|
svg_cairo_t * scr;
|
||||||
|
int bpp, btpp, stride;
|
||||||
|
unsigned int width, height;
|
||||||
|
unsigned int rwidth, rheight;
|
||||||
|
float scale;
|
||||||
|
unsigned char * image;
|
||||||
|
cairo_surface_t * cairo_surface;
|
||||||
|
cairo_t * cr;
|
||||||
|
SDL_Surface * sdl_surface, * sdl_surface_tmp;
|
||||||
|
Uint32 rmask, gmask, bmask, amask;
|
||||||
|
svg_cairo_status_t res;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Attempting to load \"%s\" as an SVG\n", file);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Create the SVG cairo stuff:
|
||||||
|
if (svg_cairo_create(&scr) != SVG_CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("svg_cairo_create() failed\n");
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the SVG file:
|
||||||
|
if (svg_cairo_parse(scr, file) != SVG_CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
svg_cairo_destroy(scr);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("svg_cairo_parse(%s) failed\n", file);
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the natural size of the SVG
|
||||||
|
svg_cairo_get_size(scr, &rwidth, &rheight);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("svg_get_size(): %d x %d\n", rwidth, rheight);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (rwidth == 0 || rheight == 0)
|
||||||
|
{
|
||||||
|
svg_cairo_destroy(scr);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("SVG %s had 0 width or height!\n", file);
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We will create a CAIRO_FORMAT_ARGB32 surface. We don't need to match
|
||||||
|
// the screen SDL format, but we are interested in the alpha bit...
|
||||||
|
bpp = 32;
|
||||||
|
btpp = 4;
|
||||||
|
|
||||||
|
// We want to render at full Tux Paint canvas size, so that the stamp
|
||||||
|
// at its largest scale remains highest quality (no pixelization):
|
||||||
|
// (but not messing up the aspect ratio)
|
||||||
|
|
||||||
|
scale = pick_best_scape(rwidth, rheight, r_canvas.w, r_canvas.h);
|
||||||
|
|
||||||
|
width = ((float) rwidth * scale);
|
||||||
|
height = ((float) rheight * scale);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("scaling to %d x %d (%f scale)\n", width, height, scale);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// scanline width
|
||||||
|
stride = width * btpp;
|
||||||
|
|
||||||
|
// Allocate space for an image:
|
||||||
|
image = calloc(stride * height, 1);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("calling cairo_image_surface_create_for_data(..., CAIRO_FORMAT_ARGB32, %d(w), %d(h), %d(stride))\n", width, height, stride);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Create the cairo surface with the adjusted width and height
|
||||||
|
cairo_surface = cairo_image_surface_create_for_data(image,
|
||||||
|
CAIRO_FORMAT_ARGB32,
|
||||||
|
width, height, stride);
|
||||||
|
|
||||||
|
cr = cairo_create(cairo_surface);
|
||||||
|
if (cr == NULL)
|
||||||
|
{
|
||||||
|
svg_cairo_destroy(scr);
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("cairo_create() failed\n");
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scale it (proportionally)
|
||||||
|
cairo_scale(cr, scale, scale); // no return value :(
|
||||||
|
|
||||||
|
// Render SVG to our surface:
|
||||||
|
res = svg_cairo_render(scr, cr);
|
||||||
|
|
||||||
|
// Clean up:
|
||||||
|
cairo_surface_destroy(cairo_surface);
|
||||||
|
cairo_destroy(cr);
|
||||||
|
svg_cairo_destroy(scr);
|
||||||
|
|
||||||
|
if (res != SVG_CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("svg_cairo_render() failed\n");
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Adjust the SDL surface to match the cairo surface created
|
||||||
|
// (surface mask of ARGB) NOTE: Is this endian-agnostic? -bjk 2006.10.25
|
||||||
|
rmask = 0x00ff0000;
|
||||||
|
gmask = 0x0000ff00;
|
||||||
|
bmask = 0x000000ff;
|
||||||
|
amask = 0xff000000;
|
||||||
|
|
||||||
|
// Create the SDL surface using the pixel data stored:
|
||||||
|
sdl_surface_tmp = SDL_CreateRGBSurfaceFrom((void *) image, width, height,
|
||||||
|
bpp, stride,
|
||||||
|
rmask, gmask, bmask, amask);
|
||||||
|
|
||||||
|
if (sdl_surface_tmp == NULL)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("SDL_CreateRGBSurfaceFrom() failed\n");
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert the SDL surface to the display format, for faster blitting:
|
||||||
|
sdl_surface = SDL_DisplayFormatAlpha(sdl_surface_tmp);
|
||||||
|
SDL_FreeSurface(sdl_surface_tmp);
|
||||||
|
|
||||||
|
if (sdl_surface == NULL)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("SDL_DisplayFormatAlpha() failed\n");
|
||||||
|
#endif
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("SDL surface from %d x %d SVG is %d x %d\n",
|
||||||
|
rwidth, rheight, sdl_surface->w, sdl_surface->h);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(sdl_surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Load an image; call load_svg() (above, to call Cairo and SVG-Cairo funcs)
|
||||||
|
// if we notice it's an SVG file,
|
||||||
|
// otherwise call SDL_Image lib's IMG_Load() (for PNGs, JPEGs, BMPs, etc.)
|
||||||
|
SDL_Surface * myIMG_Load(char * file)
|
||||||
|
{
|
||||||
|
if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".svg") == 0)
|
||||||
|
return(load_svg(file));
|
||||||
|
else
|
||||||
|
return(IMG_Load(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
float pick_best_scape(unsigned int orig_w, unsigned int orig_h,
|
||||||
|
unsigned int max_w, unsigned int max_h)
|
||||||
|
{
|
||||||
|
float aspect, scale, wscale, hscale;
|
||||||
|
|
||||||
|
aspect = (float) orig_w / (float) orig_h;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("trying to fit %d x %d (aspect: %.4f) into %d x %d\n",
|
||||||
|
orig_w, orig_h, aspect, max_w, max_h);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wscale = (float) max_w / (float) orig_w;
|
||||||
|
hscale = (float) max_h / (float) orig_h;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("max_w / orig_w = wscale: %.4f\n", wscale);
|
||||||
|
printf("max_h / orig_h = hscale: %.4f\n", hscale);
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (aspect >= 1)
|
||||||
|
{
|
||||||
|
// Image is wider-than-tall (or square)
|
||||||
|
|
||||||
|
scale = wscale;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Wider-than-tall. Using wscale.\n");
|
||||||
|
printf("new size would be: %d x %d\n",
|
||||||
|
(int) ((float) orig_w * scale),
|
||||||
|
(int) ((float) orig_h * scale));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((float) orig_h * scale > (float) max_h)
|
||||||
|
{
|
||||||
|
scale = hscale;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Too tall! Using hscale!\n");
|
||||||
|
printf("new size would be: %d x %d\n",
|
||||||
|
(int) ((float) orig_w * scale),
|
||||||
|
(int) ((float) orig_h * scale));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Taller-than-wide
|
||||||
|
|
||||||
|
scale = hscale;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Taller-than-wide. Using hscale.\n");
|
||||||
|
printf("new size would be: %d x %d\n",
|
||||||
|
(int) ((float) orig_w * scale),
|
||||||
|
(int) ((float) orig_h * scale));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((float) orig_w * scale > (float) max_w)
|
||||||
|
{
|
||||||
|
scale = wscale;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Too wide! Using wscale!\n");
|
||||||
|
printf("new size would be: %d x %d\n",
|
||||||
|
(int) ((float) orig_w * scale),
|
||||||
|
(int) ((float) orig_h * scale));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("\n");
|
||||||
|
printf("Final scale: %.4f\n", scale);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue