Added double-buffering for GUI, and PNG support

This commit is contained in:
David Capello 2007-09-20 00:32:35 +00:00
parent 7c4dbdc036
commit e82167b340
148 changed files with 49290 additions and 3965 deletions

View File

@ -42,11 +42,16 @@ THANKFULNESS
Elver Loho: For port ASE to BeOS.
Frank J. T. Wojcik, Guy Eric Schalnat, Andreas Dilger, Glenn
Randers-Pehrson: For libpng.
Gary Oberbrunner: For his code to quantize RGB images with ordered
dither method.
Javier Gonzalez: For his AllegroFont wrapper.
Jean-loup Gailly and Mark Adler: For zlib
Jens Ch. Restemeier: For GFLI, his code to save FLI files is just
"amazing".

View File

@ -1,5 +1,22 @@
2007-09-18 David A. Capello <dacap@users.sourceforge.net>
* src/dialogs/tips.c (tips_msg_proc): Added scrolling with mouse
wheel.
* src/modules/gui.c (init_module_gui): Added support for
double-buffering and "screen scaling".
* jinete/src/jsystem.c (ji_mouse_draw_cursor): Added.
* jinete/src/jsystem.c (ji_mouse_poll, ji_mouse_set_position):
Support for a "ji_screen" not equal to "screen".
* src/script/export.h: renamed "GUI_" to "dialogs_".
2007-09-13 David A. Capello <dacap@users.sourceforge.net>
* ASE 0.5 Released.
* jinete/src/jwidget.c (jwidget_check_underscored): Fixed to use
scancode instead of ASCII value returned by readkey() routine.

View File

@ -2,6 +2,16 @@
NEWS
===================================
0.6
---
- Added support for PNG files (through libpng).
- Finally screen scaling supported (with double-buffering). This means
that you can use a screen of 320x240 between a window of 640x480
(screen-scaling x2). This is the new default video mode for ASE.
- Fixed compilations errors for 4.x
- Fixed menus.es
0.5
---

View File

@ -52,12 +52,6 @@ Wish-list
position from the starting point of movement;
+ make drawing the 'marching-ants-rectangle' a prioritaire thing to
draw (when move it).
- default Windowed mode? (idea from Robert J Ohannessian);
+ I don't think so: ASE was, is and will be better in FULL-SCREEN modes;
+ Maybe a recordable "card" in the configuration file will be enough;
+ See docs/FULLSCR.txt;
+ if double buffering is implemented, that is the answer (double buffering
with a backbuffer of 320x240 and a realscreen of 640x480).
- for Jinete:
+ add columns handle to list-boxes;
+ add icons handle to all widgets (mainly button, list-items, and labels);

2
all.h
View File

@ -85,6 +85,7 @@
#include "modules/sprites.h"
#include "modules/tools.h"
#include "modules/tools2.h"
#include "png.h"
#include "raster/algo.h"
#include "raster/blend.h"
#include "raster/brush.h"
@ -135,6 +136,7 @@
#include "widgets/statebar.h"
#include "widgets/target.h"
#include "widgets/toolbar.h"
#include "zlib.h"
#include <allegro.h>
#include <allegro/base.h>
#include <allegro/color.h>

View File

@ -79,11 +79,11 @@
#
- {
"&Tips" = always "GUI_Tips(true)" <F1> ;
"&About" = always "GUI_About()" ;
"&Tips" = always "dialogs_tips(true)" <F1> ;
"&About" = always "dialogs_about()" ;
"&Refresh" = always "app_refresh_screen()" <F5> ;
----
"&Screen Saver" = always "GUI_ScreenSaver()" ;
"&Screen Saver" = always "dialogs_screen_saver()" ;
"Set &Graphics Mode" {
"&Select" = always "set_gfx(\"interactive\", 0, 0, 0)" ;
----
@ -99,9 +99,9 @@
}
----
"Screen Sh&ot" SCREENSHOT_ACCEL = always "screen_shot()" <F12> ;
"Recording Screen" = is_rec "GUI_SwitchREC()" ;
"Recording Screen" = is_rec "switch_recording_screen()" ;
----
"Reload &Menus" = always "GUI_ReloadMenus()" ;
"Reload &Menus" = always "rebuild_root_menu_with_alert()" ;
----
"Load Session" = always "GUI_LoadSession()" ;
"Save Session" = always "GUI_SaveSession()" ;
@ -134,8 +134,8 @@
"Flip &Horizontal" = has_image "GUI_FlipHorizontal()" <Shift+H> ;
"Flip &Vertical" = has_image "GUI_FlipVertical()" <Shift+V> ;
----
"R&eplace Color" = has_image "GUI_ReplaceColor()" </> ;
"&Invert" = has_image "GUI_InvertColor()" <Ctrl+I> ;
"R&eplace Color" = has_image "dialogs_replace_color()" </> ;
"&Invert" = has_image "dialogs_invert_color()" <Ctrl+I> ;
}
&Sprite {
@ -182,12 +182,12 @@ F&rame FRAME_POPUP {
"&Invert" = has_sprite "InvertMask()" <Shift+Ctrl+I> ;
# "&Shrink" = has_imagemask "selection(current_sprite, SEL_SHRINK)" ;
----
"&Color" = has_image "GUI_MaskColor()" <?> ;
"&Color" = has_image "dialogs_mask_color()" <?> ;
"S&pecial" {
"Stretch &Bottom" = has_mask "StretchMaskBottom()" ;
}
----
"Repositor&y" = has_sprite "GUI_MaskRepository()" <Shift+Ctrl+M> ;
"Repositor&y" = has_sprite "dialogs_mask_repository()" <Shift+Ctrl+M> ;
"&Load" = has_sprite "GUI_LoadMask()" ;
"&Save" = has_mask "GUI_SaveMask()" ;
}
@ -201,7 +201,7 @@ F&rame FRAME_POPUP {
&Tool {
"&Drawing Tool" {
"&Configure" = always "GUI_ToolsConfiguration()" <C> ;
"&Configure" = always "dialogs_tools_configuration()" <C> ;
----
"&Marker" = tool_marker "select_tool(\"Marker\")" <M> ;
"&Dots" = tool_dots "select_tool(\"Dots\")" <D> ;
@ -215,12 +215,12 @@ F&rame FRAME_POPUP {
# "&Oval" = tool_path "select_tool(\"Oval\")" <O> ;
}
&Filters FILTERS_POPUP {
"Convolution &Matrix" = has_image "GUI_ConvolutionMatrix()" <F9> ;
"&Color Curve" = has_image "GUI_ColorCurve()" <Ctrl+M> <F10> ;
"Convolution &Matrix" = has_image "dialogs_convolution_matrix()" <F9> ;
"&Color Curve" = has_image "dialogs_color_curve()" <Ctrl+M> <F10> ;
#"&Gaussian Blur" = has_image "gaussian_blur(current_sprite)" ;
#"&Vector Map" = has_image "GUI_VectorMap()" ;
#"&Vector Map" = has_image "dialogs_vector_map()" ;
----
"&Despeckle (median filter)" = has_image "GUI_MedianFilter()" ;
"&Despeckle (median filter)" = has_image "dialogs_median_filter()" ;
}
# "Make &Undo Animation" = has_sprite
# "sprite = make_undo_animation(current_sprite)
@ -236,13 +236,13 @@ F&rame FRAME_POPUP {
"terrain.lua" = always "include(\"examples/terrain.lua\")" ;
}
----
"Draw &Text" = has_sprite "GUI_DrawText()" ;
"&MapGen" = always "GUI_MapGen()" ;
"Draw &Text" = has_sprite "dialogs_draw_text()" ;
"&MapGen" = always "dialogs_mapgen()" ;
"&Play FLI/FLC File" = always "GUI_PlayFLI()" ;
# ----
# "Test &JID File" = always "GUI_TestJID()" ;
----
"&Options" = always "GUI_Options()" <Shift+Ctrl+O> ;
"&Options" = always "dialogs_options()" <Shift+Ctrl+O> ;
}
&View {
@ -264,7 +264,7 @@ F&rame FRAME_POPUP {
"&Close" = always "close_editor(current_editor)" <Ctrl+4> ;
}
"Fi&lm Editor" FILMEDITOR_ACCEL = has_sprite "switch_between_film_and_sprite_editor()" <Tab> ;
"&Palette Editor" = always "show_palette_editor()" <F4> ;
"&Palette Editor" = always "dialogs_palette_editor()" <F4> ;
----
"F&ilters Popup Menu" = always "show_filters_popup_menu()" <X> ;
}

View File

@ -4,11 +4,11 @@
# Spanish menus (see menus.en for more information)
- {
"&Tips" = always "GUI_Tips(true)" <F1> ;
"&Acerca de" = always "GUI_About()" ;
"&Tips" = always "dialogs_tips(true)" <F1> ;
"&Acerca de" = always "dialogs_about()" ;
"&Refrescar" = always "app_refresh_screen()" <F5> ;
----
"&Protector de Pantalla" = always "GUI_ScreenSaver()" ;
"&Protector de Pantalla" = always "dialogs_screen_saver()" ;
"Cambiar Modo &Gráfico" {
"&Seleccionar" = always "set_gfx(\"interactive\", 0, 0, 0)" ;
----
@ -24,9 +24,9 @@
}
----
"Screen Sh&ot" SCREENSHOT_ACCEL = always "screen_shot()" <F12> ;
"G&rabar Pantalla" = is_rec "GUI_SwitchREC()" ;
"G&rabar Pantalla" = is_rec "switch_recording_screen()" ;
----
"Recargar los &Menus" = always "GUI_ReloadMenus()" ;
"Recargar los &Menus" = always "rebuild_root_menu_with_alert()" ;
----
"Cargar Sesión" = always "GUI_LoadSession()" ;
"Guardar Sesión" = always "GUI_SaveSession()" ;
@ -59,8 +59,8 @@
"Flip &Horizontal" = has_image "GUI_FlipHorizontal()" <Shift+H> ;
"Flip &Vertical" = has_image "GUI_FlipVertical()" <Shift+V> ;
----
"Reemplazar Color" = has_image "GUI_ReplaceColor()" </> ;
"Invertir" = has_image "GUI_InvertColor()" <Ctrl+I> ;
"Reemplazar Color" = has_image "dialogs_replace_color()" </> ;
"Invertir" = has_image "dialogs_invert_color()" <Ctrl+I> ;
}
&Sprite {
@ -106,12 +106,12 @@ F&rame FRAME_POPUP {
"&Reseleccionar" = has_sprite "ReselectMask()" <Shift+Ctrl+D> ;
"&Invertir" = has_sprite "InvertMask()" <Shift+Ctrl+I> ;
----
"&Color" = has_image "GUI_MaskColor()" <?> ;
"&Color" = has_image "dialogs_mask_color()" <?> ;
"&Especial" {
"Estirar &Fondo" = has_mask "StretchMaskBottom()" ;
}
----
"Repositorio" = has_sprite "GUI_MaskRepository()" <Shift+Ctrl+M> ;
"Repositorio" = has_sprite "dialogs_mask_repository()" <Shift+Ctrl+M> ;
"Cargar" = has_sprite "GUI_LoadMask()" ;
"Guardar" = has_mask "GUI_SaveMask()" ;
}
@ -125,7 +125,7 @@ F&rame FRAME_POPUP {
&Tool {
"&Herramientas de Dibujo" {
"&Configurar" = always "GUI_ToolsConfiguration()" <C> ;
"&Configurar" = always "dialogs_tools_configuration()" <C> ;
----
"&Marcador" = tool_marker "select_tool(\"Marker\")" <M> ;
"Puntos" = tool_dots "select_tool(\"Dots\")" <D> ;
@ -138,11 +138,11 @@ F&rame FRAME_POPUP {
"&Elipse" = tool_ellipse "select_tool(\"Ellipse\")" <E> ;
}
&Filtros FILTERS_POPUP {
"&Matriz de Convolución" = has_image "GUI_ConvolutionMatrix()" <F9> ;
"&Curva de Color" = has_image "GUI_ColorCurve()" <Ctrl+M> <F10> ;
# "Mapa de &Vectores" = has_image "GUI_VectorMap()" <F11> ;
"&Matriz de Convolución" = has_image "dialogs_convolution_matrix()" <F9> ;
"&Curva de Color" = has_image "dialogs_color_curve()" <Ctrl+M> <F10> ;
# "Mapa de &Vectores" = has_image "dialogs_vector_map()" <F11> ;
----
"&Reducción de ruido (filtrado por mediana)" = has_image "GUI_MedianFilter()" ;
"&Reducción de ruido (filtrado por mediana)" = has_image "dialogs_median_filter()" ;
}
&Scripts {
"Cargar script desde &archivo" = always "GUI_LoadScriptFile()" <Ctrl+0> ;
@ -155,11 +155,11 @@ F&rame FRAME_POPUP {
"terrain.lua" = always "include(\"examples/terrain.lua\")" ;
}
----
"Dibujar &Texto" = has_sprite "GUI_DrawText()" ;
"&MapGen" = always "GUI_MapGen()" ;
"Dibujar &Texto" = has_sprite "dialogs_draw_text()" ;
"&MapGen" = always "dialogs_mapgen()" ;
"&Reproducir Archivo FLI/FLC" = always "GUI_PlayFLI()" ;
----
"&Opciones" = always "GUI_Options()" <Shift+Ctrl+O> ;
"&Opciones" = always "dialogs_options()" <Shift+Ctrl+O> ;
}
&Ver {
@ -180,8 +180,8 @@ F&rame FRAME_POPUP {
----
"&Cerrar" = always "close_editor(current_editor)" <Ctrl+4> ;
}
"E&ditor de Película" FILMEDITOR_ACCEL = has_sprite "switch_between_film_and_sprite_editor()" <TAB>
"&Paleta de Colores" = always "show_palette_editor()" <F4> ;
"E&ditor de Película" FILMEDITOR_ACCEL = has_sprite "switch_between_film_and_sprite_editor()" <Tab> ;
"&Paleta de Colores" = always "dialogs_palette_editor()" <F4> ;
----
"Popup Menu de &Filtros" = always "show_filters_popup_menu()" <X> ;
}

View File

@ -1,7 +1,7 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
-- Copyright (C) 2001-2005, 2007 by David A. Capello
function GUI_SwitchREC()
function switch_recording_screen()
if is_rec_screen() then
rec_screen_off()
else

View File

@ -1,9 +1,9 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
-- Copyright (C) 2001-2005, 2007 by David A. Capello
function GUI_ReloadMenus()
function rebuild_root_menu_with_alert()
if jalert(_("Warning<<If you try to reload the root-menu<<you will lost the current one.<<Do you want continue?||&Load||&Cancel"))
== 1 then
rebuild_root_menu()
== 1 then
rebuild_root_menu()
end
end

View File

@ -1,5 +1,5 @@
-- ase -- allegro-sprite-editor: the ultimate sprites factory
-- Copyright (C) 2001-2005 by David A. Capello
-- Copyright (C) 2001-2005, 2007 by David A. Capello
function GUI_SpriteProperties()
-- get current sprite
@ -60,7 +60,7 @@ function GUI_SpriteProperties()
GUI_Refresh(sprite)
break
elseif killer == jwidget_find_name(window, "speed") then
GUI_FrameLength(-1)
dialogs_frame_length(-1)
else
break
end

929
docs/script._tx Normal file
View File

@ -0,0 +1,929 @@
@#
@# Documentation about how to program scripts with ASE
@#
@document_title=ASE Scripting Manual
@html_footer=Back to contents
@rtfh=ASE - Scripting
@$\input texinfo
@$@documentlanguage es
@$@setfilename script.info
@$@settitle ASE Scripting Manual
@$@setchapternewpage odd
@$@paragraphindent 0
@$@setchapternewpage off
@# This should remain commented at the moment (dvi output) @$@finalout
@$
@$@ifinfo
@$This is the Info version of the ASE Scripting manual
@$
@$By David A. Capello
@$@end ifinfo
@$
@$@node Top, , (dir), (dir)
@titlepage
@<pre>
@!indent
ASE Scripting 0.6
By <a href="http://www.davidcapello.com.ar/">David A. Capello</a>, 2005.
@indent
@</pre>
#include &ltstd_disclaimer.h&gt
<blockquote class="text"><i>
"I do not accept responsibility for any effects, adverse or otherwise,
that this code may have on you, your computer, your sanity, your dog,
and anything else that you can think of. Use it at your own risk."
</i></blockquote>
@!titlepage
@!text
@heading
Contents
@contents
@text
@text
@heading
Introduction
ASE has scripting facilities. You can make a script (a text file)
with a set of routines to make images, effects, or anything you
think. ASE uses Lua library to do this, so you should know program
in Lua, anyway, it's really simple, so you'll not have any
inconvenient.
The complete reference of Lua language is in <a href="lua-5.0.pdf">lua-5.0.pdf</a>. Also, you
need a text editor to write Lua scripts (the Windows Notepad can
be used).
@hnode Warning about Lua
You should known that ASE uses a patched version of Lua, where you
can use the != operator instead of ~=
<codeblock>
if current_sprite != nil then
-- we can use the current_sprite variable...
end
<endblock>
@heading
Basic Lua Programming
@hnode Comments
Comments start with --
<codeblock>
-- this line will be never parsed
<endblock>
Or you can comment multiple lines
<codeblock>
--[[
blah blah blah...
]]--
<endblock>
@hnode Example 1
<codeblock>
local a = 4
local b = 5
print ("a+b is: " .. (a+b))
<endblock>
Here we define two variables "a" and "b" with the values "4" and "5"
respectively. Then we print the string "a+b is: " follower by the
result of the operation a+b (4+5) that is 9, so the final message is:
<textblock>
a+b is: 9
<endblock>
Also we could use:
<codeblock>
print (a.."+"..b.." is: "..(a+b))
<endblock>
To print:
<textblock>
4+5 is: 9
<endblock>
@hnode Example 2
<codeblock>
function add (a, b)
return a+b
end
print ("1+2 = " .. add (1, 2))
<endblock>
With the "function" keyword you define a new function, in this case
the "add" function, the names between parenthesis indicate the
arguments (parameters) that you must give to that routine.
@hnode Example 3
<codeblock>
for c = 1, 10 do
print (c)
end
<endblock>
This repeat the block between the "do" keyword and the "end" keyword
10 times (from 1 to 10 inclusive).
So this print:
<textblock>
1
2
3
4
5
6
7
8
9
10
<endblock>
@hnode Example 4
<codeblock>
for c = 1, 10 do
if c == 5 then
break
end
print (c)
end
<endblock>
In this case when "c" come to 5 the for is breaked so the other
iterations aren't made. This print:
<textblock>
1
2
3
4
<endblock>
@hnode Example 5
<codeblock>
for c = 1, 5 do
if c != 3 then
print ("c isn't 3 (c is " .. c .. ")")
else
print ("c is 3")
end
end
<endblock>
The != operator means "not equal" (negation of equality). You can
use the original Lua operator ~= too.
This print:
<textblock>
c isn't 3 (c is 1)
c isn't 3 (c is 2)
c is 3
c isn't 3 (c is 4)
c isn't 3 (c is 5)
<endblock>
@hnode Example 6
<codeblock>
local done = false
local a = 1
while not done do
print (a)
if a == 3 then
done = true
end
a = a + 1
end
<endblock>
This print:
<textblock>
1
2
3
<endblock>
And can be implemented in this way too:
<codeblock>
local a = 1
while a &lt= 3 do
print (a)
a = a + 1
end
<endblock>
@heading
ImgType
The imgtype (image-type) is the format of each pixel in a image.
Sprites have a lot of images, but all images must have the same
imgtype. The know imgtypes are: RGB, Grayscale, Indexed, Bitmap.
@hnode IMAGE_RGB
Means that the image have four components (channels or bytes) per
pixel, where the values of these components can be between 0 and 255
(256 differents tones), where 255 the maximum intensity.
RGB is RGBA really:
@tallbullets
<ul><li>
R: Red.
<li>
G: Green.
<li>
B: Blue.
<li>
A: Alpha (transparency or opacity).
</ul>
(0,0,0,0) is mask color, (0,0,0,255) is black, and (255,255,255,255)
is white.
@hnode IMAGE_GRAYSCALE
The image has two channels (two bytes) per pixel.
@tallbullets
<ul><li>
K: Luminance (or black channel)
<li>
A: Alpha (transparency or opacity).
</ul>
(0,0) is mask color, (0,255) is black, (255,255) is white.
@hnode IMAGE_INDEXED
Image uses one byte per pixel:
@tallbullets
<ul><li>
Index: index of the color that we must use from the color-palette.
</ul>
In this imgtype, each pixel hasn't the color information, only has a
reference to the color-palette (from 0 to 255, 256 colors), so the
RGB information about the color is found in the color-palette and
not in the image.
The index=0 is the mask color.
@hnode IMAGE_BITMAP
An internal imgtype to handle masks, where a pixel is a bit, and 8
pixels are a byte. 1 means selected, 0 deselected.
@heading
Standard routines
@@double @MAX (double x, double y);
Returns the maximum value.
@@double @MIN (double x, double y);
Returns the minimum value.
@@double @MID (double x, double y, double z);
Limits the y value to x and z.
@@void @include (const char *filename);
@@void @dofile (const char *filename);
Process the script that is in the file with the given filename. It's
searched in the current and in the "data/scripts" directories.
@@void @print (const char *buf);
Prints a message in the console, this is useful mainly to debug
scripts or to show errors.
@@double @rand (double min, double max);
Returns a random number between min and max values.
@heading
String routines
@@const char *@_ (const char *msgid);
Tries to translate the string msgid to the current language, the
entry must exists in the .po file.
@@int @strcmp (const char *s1, const char *s2);
Compares the two strings s1 and s2. It returns an integer less than,
equal to, or greater than zero if s1 is found, respectively, to be
less than, to match, or be greater than s2.
@heading
Math routines
@hnode Constants
PI: the ratio of a circle's circumference to its diameter (3.141592...).
@hnode Routines
@@double @fabs (double x);
Return the absolute value of the number x.
@@double @ceil (double x);
@xref floor
This funtion rounds x up to the nearest integer.
@@double @floor (double x);
@xref ceil
This funtion rounds x down to the nearest integer.
@@double @exp (double x);
@xref log
Returns the value of e (the base of natural logarithms) raised to
the power of x.
@@double @log (double x);
@xref exp, log10
Returns the natural logarithm of x.
@@double @log10 (double x);
@xref log
Returns the base-10 logarithm of x.
@@double @pow (double x, double y);
@xref sqrt
Returns the value of x raised to the power of y.
@@double @sqrt (double x);
@xref hypot, pow
Returns the non-negative square root of x.
@@double @hypot (double x, double y);
@xref sqrt
Returns the sqrt(x*x + y*y). This is the length of the hypotenuse
of a right-angle triangle with sides of length x and y, or the
distance of the point (x, y) from the origin.
@@double @cos (double x);
@xref sin, tan, acos
Returns the cosine of x, where x is given in radians.
@@double @sin (double x);
@xref cos, tan, asin
Returns the sine of x, where x is given in radians.
@@double @tan (double x);
@xref cos, sin, atan
Returns the tangent of x, where x is given in radians.
@@double @acos (double x);
@xref cos
Returns the arc cosine in radians and the value is mathematically
defined to be between 0 and PI (inclusive).
@@double @asin (double x);
@xref sin
Returns the arc sine in radians and the value is mathematically
defined to be between -PI/2 and PI/2 (inclusive).
@@double @atan (double x);
@xref tan, atan2
Returns the arc tangent in radians and the value is mathematically
defined to be between -PI/2 and PI/2 (inclusive).
@@double @atan2 (double y, double x);
@xref atan
Returns the result in radians, which is between -PI and PI
(inclusive).
@@double @cosh (double x);
Returns the hyperbolic cosine of x, which is defined mathematically
as (exp(x) + exp(-x)) / 2.
@@double @sinh (double x);
Returns the hyperbolic sine of x, which is defined mathematically as
(exp(x) - exp(-x)) / 2.
@@double @tanh (double x);
Returns the hyperbolic tangent of x, which is defined mathematically
as sinh(x) / cosh(x).
@heading
File routines
@@bool @file_exists (const char *filename);
Checks whether a file matching the given name exists, returning true
if it does.
@@char *@get_filename (const char *filename);
When passed a completely specified file path, this returns a pointer
to the filename portion. Both ´\´ and ´/´ are recognized as directory
separators.
@heading
Objects
There are a special type of variables in Lua scripts: objects
(represented with user-data). Each object can be of some of these
types:
@tallbullets
<ul><li>
Graphics objects: Image, Frame, Layer, Mask, Path, Sprite, Stock, Undo.
<li>
Effect objects: Effect, ConvMatr, Curve, CurvePoint.
<li>
GUI objects: JEvent, JList, JRect, JRegion, JWidget.
</ul>
@heading
Image
An image, has width and height, an image-type (RGB, Grayscale, etc.),
and contains the image data (pixels, pixmap, or bitmap).
@hnode Image fields
<ul><li>
[number] image.imgtype<br>
See sprite.imgtype
<li>
[number] image.w<br>
[number] image.h<br>
The width and height (in pixels) of this image.
</ul>
@hnode Image methods
@@Image *@image_new (int imgtype, int w, int h);
Creates a new image
@@Image *@image_new_copy (Image *image);
@@void @image_free (Image *image);
@@int @image_getpixel (Image *image, int x, int y);
@@void @image_putpixel (Image *image, int x, int y, int color);
@@void @image_clear (Image *image, int color);
@@void @image_copy (Image *dst, Image *src, int x, int y);
@@void @image_merge (Image *dst, Image *src, int x, int y, int opacity, int blend_mode);
@@Image *@image_crop (Image *image, int x, int y, int w, int h);
@@void @image_hline (Image *image, int x1, int y, int x2, int color);
@@void @image_vline (Image *image, int x, int y1, int y2, int color);
@@void @image_rect (Image *image, int x1, int y1, int x2, int y2, int color);
@@void @image_rectfill (Image *image, int x1, int y1, int x2, int y2, int color);
@@void @image_line (Image *image, int x1, int y1, int x2, int y2, int color);
@@void @image_ellipse (Image *image, int x1, int y1, int x2, int y2, int color);
@@void @image_ellipsefill (Image *image, int x1, int y1, int x2, int y2, int color);
@@void @image_convert (Image *dst, Image *src);
@@int @image_count_diff (Image *i1, Image *i2);
@heading
Frame
A frame of animation, it contains the position, opacity and a reference
(by index) to some image in the image's stock of the layer where this
frame is. Remember this, a frame doesn't contain the image, only a
reference to it.
@@Frame *@frame_new (int frpos, int image, int x, int y, int opacity);
@@Frame *@frame_new_copy (Frame *frame);
@@void @frame_free (Frame *frame);
@@Frame *@frame_is_link (Frame *frame, Layer *layer);
@@void @frame_set_frpos (Frame *frame, int frpos);
@@void @frame_set_image (Frame *frame, int image);
@@void @frame_set_position (Frame *frame, int x, int y);
@@void @frame_set_opacity (Frame *frame, int opacity);
@heading
Layer
A layer can be two things: a normal layer (also called image layer),
or a layer set. A layer set is a group of child layers (like
"sprite.set"). A normal layer is a complete different thing.
A normal layer has a stock of images and a list of frames, each
frame has a reference to the image's stock, so each frame uses some
image of the stock. If two frames uses the same stock images, the
first frame is called the "original frame" and all other frames are
called "links".
@@Layer *@layer_new (int imgtype);
@@Layer *@layer_set_new (void);
@@Layer *@layer_new_copy (Layer *layer);
@\Layer *@layer_new_with_image (int imgtype, int x, int y, int w, int h,
@@ int frpos);
@@void @layer_free (Layer *layer);
@@bool @layer_is_image (Layer *layer);
@@bool @layer_is_set (Layer *layer);
@@Layer *@layer_get_prev (Layer *layer);
@@Layer *@layer_get_next (Layer *layer);
@@void @layer_set_name (Layer *layer, const char *name);
@@void @layer_set_blend_mode (Layer *layer, int blend_mode);
@@void @layer_add_frame (Layer *layer, Frame *frame);
@@void @layer_remove_frame (Layer *layer, Frame *frame);
@@Frame *@layer_get_frame (Layer *layer, int frpos);
@@void @layer_add_layer (Layer *set, Layer *layer);
@@void @layer_remove_layer (Layer *set, Layer *layer);
@@void @layer_move_layer (Layer *set, Layer *layer, Layer *after);
@@void @layer_render (Layer *layer, Image *image, int x, int y, int frpos);
@\Layer *@layer_flatten (Layer *layer, int imgtype, int x, int y, int w, int h,
@@ int frmin, int frmax);
@heading
Mask
@@Mask *@mask_new (void);
@@Mask *@mask_new_copy (Mask *mask);
@@void @mask_free (Mask *mask);
@@bool @mask_is_empty (Mask *mask);
@@void @mask_set_name (Mask *mask, const char *name);
@@void @mask_move (Mask *mask, int x, int y);
@@void @mask_none (Mask *mask);
@@void @mask_invert (Mask *mask);
@@void @mask_replace (Mask *mask, int x, int y, int w, int h);
@@void @mask_union (Mask *mask, int x, int y, int w, int h);
@@void @mask_subtract (Mask *mask, int x, int y, int w, int h);
@@void @mask_intersect (Mask *mask, int x, int y, int w, int h);
@@void @mask_merge (Mask *dst, Mask *src);
@@void @mask_by_color (Mask *mask, Image *image, int color, int fuzziness);
@@void @mask_crop (Mask *mask, Image *image);
@heading
Path
@@Path *@path_new (const char *name);
@@void @path_free (Path *path);
@@void @path_set_join (Path *path, int join);
@tallbullets
<ul><li>
PATH_JOIN_MITER<br>
<li>
PATH_JOIN_ROUND<br>
<li>
PATH_JOIN_BEVEL<br>
</ul>
@@void @path_set_cap (Path *path, int cap);
@tallbullets
<ul><li>
PATH_CAP_BUTT<br>
<li>
PATH_CAP_ROUND<br>
<li>
PATH_CAP_SQUARE<br>
</ul>
@@void @path_moveto (Path *path, double x, double y);
@@void @path_lineto (Path *path, double x, double y);
@@void @path_curveto (Path *path, double control_x1, double control_y1, double control_x2, double control_y2, double end_x, double end_y);
@@void @path_close (Path *path);
@@void @path_move (Path *path, double x, double y);
@@void @path_stroke (Path *path, Image *image, int color, double brush_size);
@@void @path_fill (Path *path, Image *image, int color);
@heading
Sprite
The sprite is the main object of ASE (remember Allegro "Sprite"
Editor), and it's the structure that contains all data: layers,
frames, stocks, images, masks, paths, and undo information are
inside the same sprite.
There are a global variable of Sprite type: current_sprite. This
could be "nil" if there aren't a selected sprite in the moment.
You should known about the difference between the "current_sprite"
in scripts and the sprite in the current editor. Because when you
select a sprite with "set_current_sprite", only the "current_sprite"
global pointer is set, but the sprite in the current editor is
maintain intact. So when ASE runs a script, the "current_sprite"
will be pointing to the sprite in the current editor, but if you
change the "current_sprite" (with "set_current_sprite" routine)
you'll not get that sprite in the editor (use "sprite_show" function
instead).
@@Sprite *@sprite_new (int imgtype, int w, int h);
@@Sprite *@sprite_new_copy (Sprite *sprite);
@@Sprite *@sprite_new_flatten_copy (Sprite *sprite);
@@Sprite *@sprite_new_with_layer (int imgtype, int w, int h);
@@void @sprite_free (Sprite *sprite);
@@void @sprite_lock (Sprite *sprite);
@@void @sprite_unlock (Sprite *sprite);
@@bool @sprite_is_locked (Sprite *sprite);
@@bool @sprite_is_modified (Sprite *sprite);
@@void @sprite_was_saved (Sprite *sprite);
@@void @sprite_set_filename (Sprite *sprite, const char *filename);
@@void @sprite_set_size (Sprite *sprite, int w, int h);
@@void @sprite_set_frames (Sprite *sprite, int frames);
@@void @sprite_set_speed (Sprite *sprite, int speed);
@@void @sprite_set_path (Sprite *sprite, Path *path);
@@void @sprite_set_mask (Sprite *sprite, Mask *mask);
@@void @sprite_set_layer (Sprite *sprite, Layer *layer);
@@void @sprite_set_frpos (Sprite *sprite, int frpos);
@@void @sprite_set_imgtype (Sprite *sprite, int imgtype, int dithering_method);
@@void @sprite_add_path (Sprite *sprite, Path *path);
@@void @sprite_remove_path (Sprite *sprite, Path *path);
@@void @sprite_add_mask (Sprite *sprite, Mask *mask);
@@void @sprite_remove_mask (Sprite *sprite, Mask *mask);
@@Mask *@sprite_request_mask (Sprite *sprite, const char *name);
@@void @sprite_render (Sprite *sprite, Image *image, int x, int y);
@heading
Stock
Stock of images. Each image layer has its own image's stock to
provide images to its frames.
@@Stock *@stock_new (int imgtype);
@@Stock *@stock_new_copy (Stock *stock);
@@void @stock_free (Stock *stock);
@@int @stock_add_image (Stock *stock, Image *image);
@@void @stock_remove_image (Stock *stock, Image *image);
@@void @stock_replace_image (Stock *stock, int index, Image *image);
@@Image *@stock_get_image (Stock *stock, int index);
@heading
Undo
@@Undo *@undo_new (Sprite *sprite);
@@void @undo_free (Undo *undo);
@@void @undo_enable (Undo *undo);
@@void @undo_disable (Undo *undo);
@@bool @undo_is_enabled (Undo *undo);
@@bool @undo_is_disabled (Undo *undo);
@@bool @undo_can_undo (Undo *undo);
@@bool @undo_can_redo (Undo *undo);
@@void @undo_undo (Undo *undo);
@@void @undo_redo (Undo *undo);
@@void @undo_open (Undo *undo);
@@void @undo_close (Undo *undo);
@@void @undo_image (Undo *undo, Image *image, int x, int y, int w, int h);
@\void @undo_flip (Undo *undo, Image *image, int x1, int y1, int x2, int y2,
@@ int horz);
@@void @undo_add_image (Undo *undo, Stock *stock, Image *image);
@@void @undo_remove_image (Undo *undo, Stock *stock, Image *image);
@@void @undo_replace_image (Undo *undo, Stock *stock, int index);
@@void @undo_add_frame (Undo *undo, Layer *layer, Frame *frame);
@@void @undo_remove_frame (Undo *undo, Layer *layer, Frame *frame);
@@void @undo_add_layer (Undo *undo, Layer *set, Layer *layer);
@@void @undo_remove_layer (Undo *undo, Layer *layer);
@@void @undo_move_layer (Undo *undo, Layer *layer);
@@void @undo_set_layer (Undo *undo, Sprite *sprite);
@@void @undo_set_mask (Undo *undo, Sprite *sprite);
@heading
Effect
@@Effect *@effect_new (Sprite *sprite, const char *name);
@@void @effect_free (Effect *effect);
@@void @effect_load_target (Effect *effect);
@@void @effect_set_target (Effect *effect, bool r, bool g, bool b, bool k, bool a, bool index);
@@void @effect_set_target_rgb (Effect *effect, bool r, bool g, bool b, bool a);
@@void @effect_set_target_grayscale (Effect *effect, bool k, bool a);
@@void @effect_set_target_indexed (Effect *effect, bool r, bool g, bool b, bool index);
@@void @effect_begin (Effect *effect);
@@void @effect_begin_for_preview (Effect *effect);
@@int @effect_apply_step (Effect *effect);
@@void @effect_apply (Effect *effect);
@@void @effect_flush (Effect *effect);
@@void @effect_apply_to_image (Effect *effect, Image *image, int x, int y);
@@void @effect_apply_to_target (Effect *effect);
@heading
ConvMatr
@@ConvMatr *@convmatr_new (int w, int h);
@@ConvMatr *@convmatr_new_string (const char *format);
@@void @convmatr_free (ConvMatr *convmatr);
@hnode Convolution Matrix Effect
@@void @set_convmatr (ConvMatr *convmatr);
@@ConvMatr *@get_convmatr (void);
@@ConvMatr *@get_convmatr_by_name (const char *name);
@heading
Curve
Curve is a type to represent a function y=f(x). It's mainly used in
color-curve effect.
@@Curve *@curve_new (int type);
Creates a new curve, type can be CURVE_LINEAR or CURVE_SPLINE.
@@void @curve_free (Curve *curve);
@@void @curve_add_point (Curve *curve, CurvePoint *point);
@@void @curve_remove_point (Curve *curve, CurvePoint *point);
@hnode Color Curve Effect
@@void @set_color_curve (Curve *curve);
@heading
CurvePoint
@@CurvePoint *@curve_point_new (int x, int y);
@@void @curve_point_free (CurvePoint *point);
@heading
JEvent
@heading
JList
@heading
JRect
@hnode JRect fields
<ul><li>
[number] rect.x<br>
[number] rect.y<br>
Position of the upper-left corner of the rectangle.
<li>
[number] rect.w<br>
[number] rect.h<br>
Size of the rectangle (width and height).
</ul>
@heading
JRegion
@heading
JWidget
@!text
@$@ifinfo
@headingnocontent
Index
@index
@$@end ifinfo
@$@contents
@$@bye
@text

6
fix.sh
View File

@ -1,6 +1,6 @@
#! /bin/sh
#! /bin/bash
function readln ()
readln()
{
echo -n "$1 [$2] "
read ans
@ -103,7 +103,7 @@ case "$platform" in
"*" ) exit ;;
esac
function gen_makefile ()
gen_makefile()
{
makefile=$1

View File

@ -1,5 +1,5 @@
/* jinete - a GUI library
* Copyright (C) 2003-2005 by David A. Capello
* Copyright (C) 2003-2005, 2007 by David A. Capello
*
* Jinete is gift-ware.
*/

View File

@ -1,5 +1,5 @@
/* jinete - a GUI library
* Copyright (C) 2003-2005 by David A. Capello
* Copyright (C) 2003-2005, 2007 by David A. Capello
*
* Jinete is gift-ware.
*/
@ -65,6 +65,7 @@ enum {
int ji_mouse_get_cursor(void);
int ji_mouse_set_cursor(int type);
void ji_mouse_draw_cursor();
bool ji_mouse_poll(void);
void ji_mouse_set_position(int x, int y);

View File

@ -1,5 +1,5 @@
/* jinete - a GUI library
* Copyright (C) 2003-2005 by David A. Capello
* Copyright (C) 2003-2005, 2007 by David A. Capello
*
* Jinete is gift-ware.
*/
@ -12,6 +12,7 @@
JI_BEGIN_DECLS
struct FONT;
struct BITMAP;
struct jtheme
{
@ -25,7 +26,7 @@ struct jtheme
int scrollbar_size;
void (*destroy)(void);
void (*regen)(void);
void (*set_cursor)(int type);
struct BITMAP *(*set_cursor)(int type, int *focus_x, int *focus_y);
void (*init_widget)(JWidget widget);
JRegion (*get_window_mask)(JWidget widget);
void (*map_decorative_widget)(JWidget widget);

View File

@ -465,7 +465,7 @@ static void button_request_size(JWidget widget, int *w, int *h)
}
jwidget_get_texticon_info(widget, &box, &text, &icon,
button->icon_align, icon_w, icon_h);
button->icon_align, icon_w, icon_h);
*w = widget->border_width.l + jrect_w(&box) + widget->border_width.r;
*h = widget->border_width.t + jrect_h(&box) + widget->border_width.b;

View File

@ -1,5 +1,5 @@
/* jinete - a GUI library
* Copyright (C) 2003-2005 by David A. Capello
* Copyright (C) 2003-2005, 2007 by David A. Capello
*
* Jinete is gift-ware.
*/
@ -266,16 +266,31 @@ static JWidget convert_tag_to_widget(Tag *tag)
/* the widget was created? */
if (widget) {
Attr *name = tag_get_attr (tag, "name");
Attr *expansive = tag_get_attr (tag, "expansive");
Attr *magnetic = tag_get_attr (tag, "magnetic");
Attr *noborders = tag_get_attr (tag, "noborders");
Attr *name = tag_get_attr(tag, "name");
Attr *expansive = tag_get_attr(tag, "expansive");
Attr *magnetic = tag_get_attr(tag, "magnetic");
Attr *noborders = tag_get_attr(tag, "noborders");
Attr *width = tag_get_attr(tag, "width");
Attr *height = tag_get_attr(tag, "height");
JLink link;
if (name) jwidget_set_name (widget, name->value);
if (expansive) jwidget_expansive (widget, TRUE);
if (magnetic) jwidget_magnetic (widget, TRUE);
if (noborders) jwidget_noborders (widget);
if (name)
jwidget_set_name(widget, name->value);
if (expansive)
jwidget_expansive(widget, TRUE);
if (magnetic)
jwidget_magnetic(widget, TRUE);
if (noborders)
jwidget_noborders(widget);
if (width || height) {
int w = (width) ? strtol(width->value, NULL, 10): 0;
int h = (height) ? strtol(height->value, NULL, 10): 0;
jwidget_set_static_size(widget, w, h);
}
/* children */
JI_LIST_FOR_EACH(tag->sub_tags, link) {

View File

@ -116,12 +116,12 @@ JWidget jmanager_new(void)
old_readed_key[c] = 0;
}
widget = jwidget_new (JI_MANAGER);
widget = jwidget_new(JI_MANAGER);
jwidget_add_hook (widget, JI_MANAGER, manager_msg_proc, NULL);
jwidget_add_hook(widget, JI_MANAGER, manager_msg_proc, NULL);
jrect_replace (widget->rc, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
jwidget_show (widget);
jrect_replace(widget->rc, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
jwidget_show(widget);
/* default manager is the first one (and is ever visible) */
if (!default_manager)
@ -472,17 +472,17 @@ void jmanager_dispatch_draw_messages(void)
dispatch_msgs(TRUE);
}
JWidget jmanager_get_focus (void)
JWidget jmanager_get_focus(void)
{
return focus_widget;
}
JWidget jmanager_get_mouse (void)
JWidget jmanager_get_mouse(void)
{
return mouse_widget;
}
JWidget jmanager_get_capture (void)
JWidget jmanager_get_capture(void)
{
return capture_widget;
}
@ -683,12 +683,12 @@ void jmanager_free_focus(void)
jmanager_set_focus(NULL);
}
void jmanager_free_mouse (void)
void jmanager_free_mouse(void)
{
jmanager_set_mouse(NULL);
}
void jmanager_free_capture (void)
void jmanager_free_capture(void)
{
if (capture_widget) {
capture_widget->flags &= ~JI_HASCAPTURE;
@ -696,7 +696,7 @@ void jmanager_free_capture (void)
}
}
void jmanager_free_widget (JWidget widget)
void jmanager_free_widget(JWidget widget)
{
/* break any relationship with the GUI manager */
if (jwidget_has_capture (widget))
@ -709,33 +709,33 @@ void jmanager_free_widget (JWidget widget)
jmanager_free_focus ();
}
void jmanager_remove_message (JMessage msg)
void jmanager_remove_message(JMessage msg)
{
jlist_remove(msg_queue, msg);
}
void jmanager_remove_messages_for (JWidget widget)
void jmanager_remove_messages_for(JWidget widget)
{
JLink link;
JI_LIST_FOR_EACH(msg_queue, link)
remove_msgs_for(widget, link->data);
}
void jmanager_refresh_screen (void)
void jmanager_refresh_screen(void)
{
if (default_manager)
jwidget_invalidate (default_manager);
jwidget_invalidate(default_manager);
}
/* configures the window for begin the loop */
void _jmanager_open_window (JWidget manager, JWidget window)
void _jmanager_open_window(JWidget manager, JWidget window)
{
JMessage msg;
/* free all widgets of special states */
jmanager_free_capture ();
jmanager_free_mouse ();
jmanager_free_focus ();
jmanager_free_capture();
jmanager_free_mouse();
jmanager_free_focus();
/* add the window to manager */
jlist_prepend(manager->children, window);
@ -745,17 +745,17 @@ void _jmanager_open_window (JWidget manager, JWidget window)
jwidget_emit_signal(manager, JI_SIGNAL_MANAGER_ADD_WINDOW);
/* broadcast the open message */
msg = jmessage_new (JM_OPEN);
jmessage_broadcast_to_children (msg, window);
jmanager_send_message (msg);
jmessage_free (msg);
msg = jmessage_new(JM_OPEN);
jmessage_broadcast_to_children(msg, window);
jmanager_send_message(msg);
jmessage_free(msg);
/* update the new windows list to show */
jlist_append(new_windows, window);
}
void _jmanager_close_window(JWidget manager, JWidget window,
bool sendtokill, bool redraw_background)
bool sendtokill, bool redraw_background)
{
JMessage msg;
JRegion reg1;

View File

@ -1,5 +1,5 @@
/* jinete - a GUI library
* Copyright (C) 2003-2005 by David A. Capello
* Copyright (C) 2003-2005, 2007 by David A. Capello
*
* Jinete is gift-ware.
*/

View File

@ -28,6 +28,9 @@ static const char *(*strings_hook)(const char *msgid) = NULL;
/* Current mouse cursor type. */
static int m_cursor;
static BITMAP *sprite_cursor = NULL;
static int focus_x;
static int focus_y;
/* Mouse information (button and position). */
@ -46,6 +49,7 @@ static volatile int click_mouse_b = 0;
/* Local routines. */
static void set_cursor(BITMAP *bmp, int x, int y);
static void clock_inc(void);
static void check_click(void);
@ -103,7 +107,17 @@ static void check_click(void)
click_level = JI_CLICK_NOT;
}
END_OF_STATIC_FUNCTION (check_click);
END_OF_STATIC_FUNCTION(check_click);
static void set_cursor(BITMAP *bmp, int x, int y)
{
sprite_cursor = bmp;
focus_x = x;
focus_y = y;
set_mouse_sprite(bmp);
set_mouse_sprite_focus(x, y);
}
int _ji_system_init(void)
{
@ -146,7 +160,7 @@ void ji_set_screen(BITMAP *bmp)
ji_mouse_set_cursor(JI_CURSOR_NULL);
ji_screen = bmp;
if(ji_screen) {
if (ji_screen) {
JWidget manager = ji_get_default_manager();
/* update default-manager size */
@ -181,25 +195,52 @@ int ji_mouse_get_cursor(void)
int ji_mouse_set_cursor(int type)
{
JTheme theme = ji_get_theme ();
JTheme theme = ji_get_theme();
int old = m_cursor;
m_cursor = type;
if (m_cursor == JI_CURSOR_NULL) {
show_mouse (NULL);
set_mouse_sprite (NULL);
show_mouse(NULL);
set_cursor(NULL, 0, 0);
}
else {
show_mouse (NULL);
if (theme->set_cursor)
(*theme->set_cursor) (m_cursor);
show_mouse (ji_screen);
show_mouse(NULL);
if (theme->set_cursor) {
BITMAP *sprite;
int x = 0;
int y = 0;
sprite = (*theme->set_cursor)(m_cursor, &x, &y);
set_cursor(sprite, x, y);
}
if (ji_screen == screen)
show_mouse(ji_screen);
}
return old;
}
/**
* Use this routine if your "ji_screen" isn't Allegro's "screen" so
* you must to draw the cursor by your self using this routine.
*/
void ji_mouse_draw_cursor()
{
if (sprite_cursor != NULL) {
int x = m_x[0]-focus_x;
int y = m_y[0]-focus_y;
JRect rect = jrect_new(x, y,
x+sprite_cursor->w,
y+sprite_cursor->h);
jwidget_invalidate_rect(ji_get_default_manager(), rect);
draw_sprite(ji_screen, sprite_cursor, x, y);
jrect_free(rect);
}
}
/* Returns TRUE if the mouse moved. */
bool ji_mouse_poll(void)
@ -209,17 +250,30 @@ bool ji_mouse_poll(void)
m_y[1] = m_y[0];
m_z[1] = m_z[0];
poll_mouse ();
poll_mouse();
m_b[0] = mouse_b;
m_x[0] = mouse_x;
m_y[0] = mouse_y;
m_z[0] = mouse_z;
if ((m_x[0] != m_x[1]) || (m_y[0] != m_y[1])) {
poll_mouse ();
if (ji_screen == screen) {
m_x[0] = mouse_x;
m_y[0] = mouse_y;
}
else {
m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;
}
if ((m_x[0] != m_x[1]) || (m_y[0] != m_y[1])) {
poll_mouse();
if (ji_screen == screen) {
m_x[0] = mouse_x;
m_y[0] = mouse_y;
}
else {
m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;
}
moved = TRUE;
}
@ -234,8 +288,17 @@ bool ji_mouse_poll(void)
void ji_mouse_set_position(int x, int y)
{
moved = TRUE;
position_mouse(m_x[0] = m_x[1] = x,
m_y[0] = m_y[1] = y);
m_x[0] = m_x[1] = x;
m_y[0] = m_y[1] = y;
if (ji_screen == screen) {
position_mouse(x, y);
}
else {
position_mouse(SCREEN_W * x / JI_SCREEN_W,
SCREEN_H * y / JI_SCREEN_H);
}
}
int ji_mouse_x(int antique) { return m_x[antique & 1]; }

View File

@ -28,13 +28,13 @@ int ji_register_widget_type (void)
/* creates a new widget with an unique JID */
JWidget jwidget_new (int type)
{
JWidget widget = _ji_get_new_widget ();
JWidget widget = _ji_get_new_widget();
if (!widget)
return NULL;
widget->type = type;
widget->name = NULL;
widget->rc = jrect_new (0, 0, 0, 0);
widget->rc = jrect_new(0, 0, 0, 0);
widget->border_width.l = 0;
widget->border_width.t = 0;
widget->border_width.r = 0;
@ -828,6 +828,8 @@ void jwidget_get_texticon_info (JWidget widget,
int box_x, box_y, box_w, box_h, icon_x, icon_y;
int text_x, text_y, text_w, text_h;
text_x = text_y = 0;
/* size of the text */
if (widget->text) {
text_w = jwidget_get_text_length (widget);
@ -941,18 +943,18 @@ void jwidget_set_rect (JWidget widget, JRect rect)
jmessage_free (msg);
}
void jwidget_set_static_size (JWidget widget, int w, int h)
void jwidget_set_static_size(JWidget widget, int w, int h)
{
widget->static_w = w;
widget->static_h = h;
}
void jwidget_set_bg_color (JWidget widget, int color)
void jwidget_set_bg_color(JWidget widget, int color)
{
widget->bg_color = color;
}
void jwidget_set_theme (JWidget widget, JTheme theme)
void jwidget_set_theme(JWidget widget, JTheme theme)
{
widget->theme = theme;
/* XXX mmhhh... maybe some JStyle in JWidget should be great */
@ -1062,11 +1064,11 @@ void jwidget_invalidate_region(JWidget widget, const JRegion region)
}
void jwidget_scroll(JWidget widget, int dx, int dy, const JRect rect,
JRegion update_region)
JRegion update_region)
{
JRegion reg1 = jwidget_get_drawable_region(widget,
JI_GDR_CUTTOPWINDOWS |
JI_GDR_USECHILDAREA);
JI_GDR_CUTTOPWINDOWS |
JI_GDR_USECHILDAREA);
JRegion reg2 = jregion_new(rect, 0);
jregion_intersect(reg1, reg1, reg2);
@ -1202,25 +1204,25 @@ void jwidget_capture_mouse(JWidget widget)
if (!jmanager_get_capture()) {
jmanager_set_capture(widget);
if (jmanager_get_capture () == widget)
if (jmanager_get_capture() == widget)
widget->flags &= ~JI_HARDCAPTURE;
}
}
void jwidget_hard_capture_mouse (JWidget widget)
void jwidget_hard_capture_mouse(JWidget widget)
{
if (!jmanager_get_capture ()) {
jmanager_set_capture (widget);
if (!jmanager_get_capture()) {
jmanager_set_capture(widget);
if (jmanager_get_capture () == widget)
if (jmanager_get_capture() == widget)
widget->flags |= JI_HARDCAPTURE;
}
}
void jwidget_release_mouse (JWidget widget)
void jwidget_release_mouse(JWidget widget)
{
if (jmanager_get_capture () == widget) {
jmanager_free_capture ();
if (jmanager_get_capture() == widget) {
jmanager_free_capture();
widget->flags &= ~JI_HARDCAPTURE;
}
@ -1351,7 +1353,7 @@ static bool widget_msg_proc (JWidget widget, JMessage msg)
}
#else
if (!(widget->flags & JI_HIDDEN)) /* is visible? */
jwidget_invalidate_region (widget, msg->drawrgn.region);
jwidget_invalidate_region(widget, msg->drawrgn.region);
#endif
return TRUE;

View File

@ -14,7 +14,7 @@
static void theme_destroy (void);
static void theme_regen (void);
static void theme_set_cursor (int type);
static BITMAP *theme_set_cursor (int type, int *focus_x, int *focus_y);
static void theme_init_widget (JWidget widget);
static JRegion theme_get_window_mask (JWidget widget);
static void theme_map_decorative_widget (JWidget widget);
@ -97,9 +97,11 @@ static void theme_regen (void)
theme->textbox_bg_color = makecol(255,255,255);
}
static void theme_set_cursor (int type)
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
{
set_mouse_sprite (NULL);
*focus_x = 0;
*focus_y = 0;
return NULL;
}
static void theme_init_widget (JWidget widget)

View File

@ -62,7 +62,7 @@ static BITMAP *icons_bitmap[ICONS] = {
static void theme_destroy(void);
static void theme_regen(void);
static void theme_set_cursor(int type);
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y);
static void theme_init_widget(JWidget widget);
static JRegion theme_get_window_mask(JWidget widget);
static void theme_map_decorative_widget(JWidget widget);
@ -183,28 +183,33 @@ static void theme_regen (void)
}
}
static void theme_set_cursor (int type)
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
{
BITMAP *sprite = NULL;
int icon_index = type-1+FIRST_CURSOR;
*focus_x = 0;
*focus_y = 0;
if (icon_index >= FIRST_CURSOR && icon_index <= LAST_CURSOR) {
if (icons_bitmap[icon_index])
set_mouse_sprite (icons_bitmap[icon_index]);
sprite = icons_bitmap[icon_index];
switch (type) {
case JI_CURSOR_NULL:
case JI_CURSOR_NORMAL:
case JI_CURSOR_NORMAL_ADD:set_mouse_sprite_focus ( 0, 0); break;
case JI_CURSOR_HAND: set_mouse_sprite_focus ( 5, 3); break;
case JI_CURSOR_MOVE: set_mouse_sprite_focus ( 8, 8); break;
/* case JI_CURSOR_SIZE_TL: set_mouse_sprite_focus (15, 15); break; */
/* case JI_CURSOR_SIZE_T: set_mouse_sprite_focus ( 8, 15); break; */
/* case JI_CURSOR_SIZE_TR: set_mouse_sprite_focus ( 0, 15); break; */
/* case JI_CURSOR_SIZE_L: set_mouse_sprite_focus (15, 8); break; */
/* case JI_CURSOR_SIZE_R: set_mouse_sprite_focus ( 0, 8); break; */
/* case JI_CURSOR_SIZE_BL: set_mouse_sprite_focus (15, 0); break; */
/* case JI_CURSOR_SIZE_B: set_mouse_sprite_focus ( 8, 0); break; */
/* case JI_CURSOR_SIZE_BR: set_mouse_sprite_focus ( 0, 0); break; */
case JI_CURSOR_NORMAL_ADD:
*focus_x = 0;
*focus_y = 0;
break;
case JI_CURSOR_HAND:
*focus_x = 5;
*focus_y = 3;
break;
case JI_CURSOR_MOVE:
*focus_x = 8;
*focus_y = 8;
break;
case JI_CURSOR_SIZE_TL:
case JI_CURSOR_SIZE_T:
case JI_CURSOR_SIZE_TR:
@ -212,12 +217,17 @@ static void theme_set_cursor (int type)
case JI_CURSOR_SIZE_R:
case JI_CURSOR_SIZE_BL:
case JI_CURSOR_SIZE_B:
case JI_CURSOR_SIZE_BR: set_mouse_sprite_focus (8, 8); break;
case JI_CURSOR_SIZE_BR:
*focus_x = 8;
*focus_y = 8;
break;
}
}
return sprite;
}
static void theme_init_widget (JWidget widget)
static void theme_init_widget(JWidget widget)
{
#define BORDER(n) \
widget->border_width.l = n; \
@ -238,35 +248,37 @@ static void theme_init_widget (JWidget widget)
switch (widget->draw_type) {
case JI_BOX:
BORDER (0);
widget->child_spacing = 2;
BORDER(0);
/* widget->child_spacing = 2; */
widget->child_spacing = 4;
break;
case JI_BUTTON:
BORDER (4);
BORDER(4);
widget->child_spacing = 0;
break;
case JI_CHECK:
BORDER (2);
widget->child_spacing = 2;
BORDER(2);
/* widget->child_spacing = 2; */
widget->child_spacing = 4;
break;
case JI_ENTRY:
BORDER (3);
BORDER(3);
break;
case JI_LABEL:
BORDER (1);
BORDER(1);
break;
case JI_LISTBOX:
BORDER (0);
BORDER(0);
widget->child_spacing = 0;
break;
case JI_LISTITEM:
BORDER (1);
BORDER(1);
break;
case JI_MENU:
@ -288,7 +300,8 @@ static void theme_init_widget (JWidget widget)
case JI_RADIO:
BORDER (2);
widget->child_spacing = 2;
/* widget->child_spacing = 2; */
widget->child_spacing = 4;
break;
case JI_SEPARATOR:
@ -342,7 +355,8 @@ static void theme_init_widget (JWidget widget)
case JI_WINDOW:
if (!jwindow_is_desktop (widget)) {
if (widget->text) {
BORDER4(4, 4+jwidget_get_text_height(widget)+4, 4, 4);
/* BORDER4(4, 4+jwidget_get_text_height(widget)+4, 4, 4); */
BORDER4(6, 4+jwidget_get_text_height(widget)+4, 6, 6);
#if 1 /* add close button */
if (!(widget->flags & JI_INITIALIZED)) {
JWidget button = jbutton_new("x");
@ -362,7 +376,8 @@ static void theme_init_widget (JWidget widget)
else {
BORDER (0);
}
widget->child_spacing = 2;
/* widget->child_spacing = 2; */
widget->child_spacing = 4;
break;
default:

View File

@ -1,4 +1,4 @@
# Copyright (C) 2001-2005 by David A. Capello -*-Makefile-*-
# Copyright (C) 2001-2005, 2007 by David A. Capello -*-Makefile-*-
.PHONY = _default
_default: default
@ -10,9 +10,13 @@ CFLAGS += -Wall -I. -Isrc -Ijinete/include -Ithird_party \
-I$(JINETE_DIR)/freetype/include \
-I$(LIBLUA_DIR)/include \
-I$(LIBGFLI_DIR) \
-Wno-deprecated-declarations
-I$(LIBPNG_DIR) \
-I$(ZLIB_DIR) \
-Wno-deprecated-declarations \
-DPNG_NO_MMX_CODE
LFLAGS += $(JINETE_LIB) $(LIBLUA_LIB) $(LIBGFLI_LIB) $(LIBART_LIB)
LFLAGS += $(JINETE_LIB) $(LIBLUA_LIB) $(LIBGFLI_LIB) $(LIBART_LIB) \
$(LIBPNG_LIB) $(ZLIB_LIB)
ifdef PROFILE
CFLAGS += -pg
@ -67,6 +71,14 @@ $(LIBART_LIB): $(LIBART_OBJS)
-rm -f $@
ar rs $@ $^
$(LIBPNG_LIB): $(LIBPNG_OBJS)
-rm -f $@
ar rs $@ $^
$(ZLIB_LIB): $(ZLIB_OBJS)
-rm -f $@
ar rs $@ $^
######################################################################
# Rules to build objects and the application
@ -89,6 +101,8 @@ VPATH = src \
$(LIBLUA_DIR)/src/lib \
$(LIBGFLI_DIR) \
$(LIBART_DIR) \
$(LIBPNG_DIR) \
$(ZLIB_DIR) \
$(JINETE_DIR)/src \
$(JINETE_DIR)/src/themes \
$(JINETE_DIR)/freetype/src/base \
@ -113,7 +127,8 @@ ASE_DEPS = config.h.gch
else
ASE_DEPS =
endif
ASE_DEPS += $(ASE_OBJS) $(JINETE_LIB) $(LIBART_LIB) $(LIBGFLI_LIB) $(LIBLUA_LIB)
ASE_DEPS += $(ASE_OBJS) $(JINETE_LIB) $(LIBART_LIB) $(LIBGFLI_LIB) \
$(LIBLUA_LIB) $(LIBPNG_LIB) $(ZLIB_LIB)
ifdef USE_PRECOMPILED_HEADER
config.h.gch: config.h

View File

@ -1,4 +1,4 @@
# Copyright (C) 2001-2005 by David A. Capello -*-Makefile-*-
# Copyright (C) 2001-2005, 2007 by David A. Capello -*-Makefile-*-
######################################################################
# ASE
@ -54,6 +54,7 @@ ASE_SOURCES = \
src/file/ico.c \
src/file/jpeg.c \
src/file/pcx.c \
src/file/png_file.c \
src/file/tga.c \
src/file/gif.c \
src/file/gif/format.c \
@ -223,6 +224,55 @@ LIBART_OBJS = $(addprefix $(OBJ_DIR)/, \
$(addsuffix $(OBJ), \
$(notdir $(basename $(LIBART_SOURCES)))))
######################################################################
# LibPNG
LIBPNG_LIB = $(OBJ_DIR)/libpng$(LIB)
LIBPNG_DIR = third_party/libpng
LIBPNG_SOURCES = \
$(LIBPNG_DIR)/png.c \
$(LIBPNG_DIR)/pngerror.c \
$(LIBPNG_DIR)/pngget.c \
$(LIBPNG_DIR)/pngmem.c \
$(LIBPNG_DIR)/pngpread.c \
$(LIBPNG_DIR)/pngread.c \
$(LIBPNG_DIR)/pngrio.c \
$(LIBPNG_DIR)/pngrtran.c \
$(LIBPNG_DIR)/pngrutil.c \
$(LIBPNG_DIR)/pngset.c \
$(LIBPNG_DIR)/pngtrans.c \
$(LIBPNG_DIR)/pngwio.c \
$(LIBPNG_DIR)/pngwrite.c \
$(LIBPNG_DIR)/pngwtran.c \
$(LIBPNG_DIR)/pngwutil.c
LIBPNG_OBJS = $(addprefix $(OBJ_DIR)/, \
$(addsuffix $(OBJ), \
$(notdir $(basename $(LIBPNG_SOURCES)))))
######################################################################
# ZLib
ZLIB_LIB = $(OBJ_DIR)/libzlib$(LIB)
ZLIB_DIR = third_party/zlib
ZLIB_SOURCES = \
$(ZLIB_DIR)/adler32.c \
$(ZLIB_DIR)/compress.c \
$(ZLIB_DIR)/crc32.c \
$(ZLIB_DIR)/deflate.c \
$(ZLIB_DIR)/gzio.c \
$(ZLIB_DIR)/infback.c \
$(ZLIB_DIR)/inffast.c \
$(ZLIB_DIR)/inflate.c \
$(ZLIB_DIR)/inftrees.c \
$(ZLIB_DIR)/trees.c \
$(ZLIB_DIR)/uncompr.c \
$(ZLIB_DIR)/zutil.c
ZLIB_OBJS = $(addprefix $(OBJ_DIR)/, \
$(addsuffix $(OBJ), \
$(notdir $(basename $(ZLIB_SOURCES)))))
######################################################################
# All objects and libraries
@ -230,9 +280,11 @@ ALL_OBJS = \
$(ASE_OBJS) \
$(LIBLUA_OBJS) \
$(LIBGFLI_OBJS) \
$(LIBART_OBJS)
$(LIBART_OBJS) \
$(LIBPNG_OBJS)
ALL_LIBS = \
$(LIBLUA_LIB) \
$(LIBGFLI_LIB) \
$(LIBART_LIB)
$(LIBART_LIB) \
$(LIBPNG_LIB)

View File

@ -16,11 +16,12 @@ endif
CFLAGS =
# LFLAGS = -Wl,--subsystem,windows
LFLAGS = -mconsole
# LFLAGS = -mwindows
# LFLAGS = -mconsole
LFLAGS = -mwindows
#LFLAGS_LAST = -lalleg -lmoldname-msvc
# LFLAGS_LAST = -lalleg -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32 -lcomctl32 -lsecur32 -lmsimg32
LFLAGS_LAST = -lalleg
# LFLAGS_LAST = -lalleg
LFLAGS_LAST = -lalld
WITHICON = 1
######################################################################

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -40,11 +40,13 @@ static int console_counter = 0;
static bool console_locked;
static bool want_close_flag = FALSE;
void console_open (void)
void console_open(void)
{
console_counter++;
if (!screen ||
/* TODO verify if the ji_screen works */
/* if (!screen || */
if (!ji_screen ||
!is_interactive () ||
wid_console ||
console_counter > 1)
@ -125,12 +127,12 @@ void console_printf (const char *format, ...)
if (!console_locked) {
console_locked = TRUE;
jwidget_set_static_size (wid_view, SCREEN_W*9/10, SCREEN_H*6/10);
jwidget_show (wid_view);
jwidget_set_static_size(wid_view, JI_SCREEN_W*9/10, JI_SCREEN_H*6/10);
jwidget_show(wid_view);
jwindow_remap (wid_console);
jwindow_center (wid_console);
jwidget_dirty (wid_console);
jwindow_remap(wid_console);
jwindow_center(wid_console);
jwidget_dirty(wid_console);
}
text = jwidget_get_text (wid_textbox);
@ -187,8 +189,8 @@ void add_progress (int max)
void del_progress (void)
{
JWidget status_bar = app_get_status_bar ();
JWidget status_bar = app_get_status_bar();
if (status_bar)
status_bar_del_progress (status_bar);
status_bar_del_progress(status_bar);
}

View File

@ -171,79 +171,79 @@ void app_loop(void)
PRINTF("GUI mode\n");
/* setup the GUI screen */
ji_mouse_set_cursor (JI_CURSOR_NORMAL);
jmanager_refresh_screen ();
ji_mouse_set_cursor(JI_CURSOR_NORMAL);
jmanager_refresh_screen();
/* load main window */
top_window = load_widget ("main.jid", "main_window");
top_window = load_widget("main.jid", "main_window");
if (!top_window)
return;
box_menu_bar = jwidget_find_name (top_window, "menu_bar");
box_editors = jwidget_find_name (top_window, "editor");
box_color_bar = jwidget_find_name (top_window, "color_bar");
box_tool_bar = jwidget_find_name (top_window, "tool_bar");
box_status_bar = jwidget_find_name (top_window, "status_bar");
box_menu_bar = jwidget_find_name(top_window, "menu_bar");
box_editors = jwidget_find_name(top_window, "editor");
box_color_bar = jwidget_find_name(top_window, "color_bar");
box_tool_bar = jwidget_find_name(top_window, "tool_bar");
box_status_bar = jwidget_find_name(top_window, "status_bar");
menu_bar = jmenubar_new ();
status_bar = status_bar_new ();
color_bar = color_bar_new (box_color_bar->align);
tool_bar = tool_bar_new (box_tool_bar->align);
view = editor_view_new ();
editor = create_new_editor ();
menu_bar = jmenubar_new();
status_bar = status_bar_new();
color_bar = color_bar_new(box_color_bar->align);
tool_bar = tool_bar_new(box_tool_bar->align);
view = editor_view_new();
editor = create_new_editor();
/* configure all widgets to expansives */
jwidget_expansive (menu_bar, TRUE);
jwidget_expansive (status_bar, TRUE);
jwidget_expansive (color_bar, TRUE);
jwidget_expansive (tool_bar, TRUE);
jwidget_expansive (view, TRUE);
jwidget_expansive(menu_bar, TRUE);
jwidget_expansive(status_bar, TRUE);
jwidget_expansive(color_bar, TRUE);
jwidget_expansive(tool_bar, TRUE);
jwidget_expansive(view, TRUE);
/* prepare the first editor */
jview_attach (view, editor);
jview_attach(view, editor);
/* setup the menus */
jmenubar_set_menu (menu_bar, get_root_menu ());
jmenubar_set_menu(menu_bar, get_root_menu());
/* start text of status bar */
app_default_status_bar_message ();
app_default_status_bar_message();
/* add the widgets in the boxes */
jwidget_add_child (box_menu_bar, menu_bar);
jwidget_add_child (box_editors, view);
jwidget_add_child (box_color_bar, color_bar);
jwidget_add_child (box_tool_bar, tool_bar);
jwidget_add_child (box_status_bar, status_bar);
jwidget_add_child(box_menu_bar, menu_bar);
jwidget_add_child(box_editors, view);
jwidget_add_child(box_color_bar, color_bar);
jwidget_add_child(box_tool_bar, tool_bar);
jwidget_add_child(box_status_bar, status_bar);
/* layout */
if (!get_config_bool ("Layout", "MenuBar", TRUE)) jwidget_hide (menu_bar);
if (!get_config_bool ("Layout", "StatusBar", TRUE)) jwidget_hide (status_bar);
if (!get_config_bool ("Layout", "ColorBar", TRUE)) jwidget_hide (color_bar);
if (!get_config_bool ("Layout", "ToolBar", TRUE)) jwidget_hide (tool_bar);
if (!get_config_bool("Layout", "MenuBar", TRUE)) jwidget_hide(menu_bar);
if (!get_config_bool("Layout", "StatusBar", TRUE)) jwidget_hide(status_bar);
if (!get_config_bool("Layout", "ColorBar", TRUE)) jwidget_hide(color_bar);
if (!get_config_bool("Layout", "ToolBar", TRUE)) jwidget_hide(tool_bar);
/* prepare the window */
jwindow_remap (top_window);
jwindow_remap(top_window);
/* rebuild menus */
app_realloc_sprite_list ();
app_realloc_recent_list ();
app_realloc_sprite_list();
app_realloc_recent_list();
/* set current editor */
set_current_editor (editor);
set_current_editor(editor);
/* open the window */
jwindow_open (top_window);
jwindow_open(top_window);
/* refresh the screen */
jmanager_refresh_screen ();
jmanager_refresh_screen();
}
/* load all startup scripts */
load_all_scripts ();
load_all_scripts();
/* set background mode for non-GUI modes */
if (!(ase_mode & MODE_GUI))
set_display_switch_mode (SWITCH_BACKAMNESIA);
set_display_switch_mode(SWITCH_BACKAMNESIA);
/* procress commands */
PRINTF("Processing commands...\n");
@ -257,36 +257,36 @@ void app_loop(void)
Sprite *sprite;
/* load the sprite */
sprite = sprite_load (command->data);
sprite = sprite_load(command->data);
if (!sprite) {
/* error */
if (ase_mode & MODE_GUI)
jalert (_("Error<<Error loading file \"%s\"||&Close"), command->data);
jalert(_("Error<<Error loading file \"%s\"||&Close"), command->data);
else
user_printf (_("Error loading file \"%s\"\n"), command->data);
user_printf(_("Error loading file \"%s\"\n"), command->data);
}
else {
/* mount and select the sprite */
sprite_mount (sprite);
set_current_sprite (sprite);
sprite_mount(sprite);
set_current_sprite(sprite);
if (ase_mode & MODE_GUI) {
/* show it */
set_sprite_in_more_reliable_editor (get_first_sprite ());
set_sprite_in_more_reliable_editor(get_first_sprite());
/* recent file */
recent_file (command->data);
recent_file(command->data);
}
}
break;
}
case DO_SCRIPT_FILE:
do_script_file (command->data);
do_script_file(command->data);
break;
case DO_SCRIPT_EXPR:
do_script_expr (command->data);
do_script_expr(command->data);
break;
}
command_free(command);
@ -301,13 +301,13 @@ void app_loop(void)
/* run the GUI */
else if (ase_mode & MODE_GUI) {
/* select language */
GUI_SelectLanguage(FALSE);
dialogs_select_language(FALSE);
/* show tips? */
if (!current_sprite)
GUI_Tips(FALSE);
dialogs_tips(FALSE);
run_gui();
gui_run();
}
/* destroy GUI widgets */
@ -350,8 +350,8 @@ void app_exit(void)
/* final copyright message */
if (ase_mode & MODE_GUI) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
printf(_("ASE is copyright (C) 2001-2005, 2007 by David A. Capello\n"
"Report bugs to <%s>.\n"), BUGREPORT);
printf("ASE - " COPYRIGHT "\n%s <%s>.\n",
_("Report bugs to"), BUGREPORT);
}
intl_exit();
@ -675,7 +675,7 @@ static void usage(int status)
/* copyright */
console_printf
("ase %s -- allegro-sprite-editor, %s\n"
"Copyright (C) 2001-2005, 2007 David A. Capello\n\n",
COPYRIGHT "\n\n",
VERSION, _("The Ultimate Sprites Factory"));
/* usage */

View File

@ -455,7 +455,13 @@ static void load_config_file(CONFIG **config, AL_CONST char *filename, AL_CONST
return;
}
#if (MAKE_VERSION(4, 2, 0) < MAKE_VERSION(ALLEGRO_VERSION, \
ALLEGRO_SUB_VERSION, \
ALLEGRO_WIP_VERSION))
length = file_size(filename);
#else
length = file_size_ex(filename);
#endif
if (length > 0) {
PACKFILE *f = pack_fopen(filename, F_READ);

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -44,8 +44,8 @@
typedef struct Module
{
const char *name;
int (*init) (void);
void (*exit) (void);
int (*init)(void);
void (*exit)(void);
int reqs;
int installed;
} Module;
@ -70,16 +70,16 @@ static Module module[] =
DEF_MODULE(editors, REQUIRE_INTERFACE),
};
static int modules = sizeof (module) / sizeof (Module);
static int modules = sizeof(module) / sizeof(Module);
int modules_init (int requirements)
int modules_init(int requirements)
{
int c;
for (c=0; c<modules; c++)
if (module[c].reqs & requirements) {
PRINTF ("Installing module: %s\n", module[c].name);
if ((*module[c].init) () < 0)
PRINTF("Installing module: %s\n", module[c].name);
if ((*module[c].init)() < 0)
return -1;
module[c].installed = TRUE;
}
@ -87,14 +87,14 @@ int modules_init (int requirements)
return 0;
}
void modules_exit (void)
void modules_exit(void)
{
int c;
for (c=modules-1; c>=0; c--)
if (module[c].installed) {
PRINTF ("Unstalling module: %s\n", module[c].name);
(*module[c].exit) ();
PRINTF("Unstalling module: %s\n", module[c].name);
(*module[c].exit)();
module[c].installed = FALSE;
}
}

View File

@ -50,37 +50,37 @@ static bool do_shutdown = FALSE;
#endif
#endif
static void do_shutdown_exit (void);
static void do_shutdown_exit(void);
#ifdef ALLEGRO_MINGW32
static void signal_handler (int sig);
static void signal_handler(int sig);
#endif
void init_shutdown_handler (void)
void init_shutdown_handler(void)
{
atexit(do_shutdown_exit);
_add_exit_func(do_shutdown_exit, "do_shutdown_exit");
#ifdef ALLEGRO_MINGW32
old_sig_abrt = signal (SIGABRT, signal_handler);
old_sig_fpe = signal (SIGFPE, signal_handler);
old_sig_ill = signal (SIGILL, signal_handler);
old_sig_segv = signal (SIGSEGV, signal_handler);
old_sig_term = signal (SIGTERM, signal_handler);
old_sig_int = signal (SIGINT, signal_handler);
old_sig_abrt = signal(SIGABRT, signal_handler);
old_sig_fpe = signal(SIGFPE, signal_handler);
old_sig_ill = signal(SIGILL, signal_handler);
old_sig_segv = signal(SIGSEGV, signal_handler);
old_sig_term = signal(SIGTERM, signal_handler);
old_sig_int = signal(SIGINT, signal_handler);
#ifdef SIGQUIT
old_sig_quit = signal (SIGQUIT, signal_handler);
old_sig_quit = signal(SIGQUIT, signal_handler);
#endif
#endif
do_shutdown = TRUE;
}
void remove_shutdown_handler (void)
void remove_shutdown_handler(void)
{
do_shutdown = FALSE;
_remove_exit_func (do_shutdown_exit);
_remove_exit_func(do_shutdown_exit);
#if defined(ALLEGRO_WINDOWS) && !defined(_MSC_VER)
/* remove emergency exit signal handlers */
signal(SIGABRT, old_sig_abrt);
@ -92,10 +92,10 @@ void remove_shutdown_handler (void)
#ifdef SIGQUIT
signal(SIGQUIT, old_sig_quit);
#endif
#endif
#endif
}
static void do_shutdown_exit (void)
static void do_shutdown_exit(void)
{
char buf[1024], path[1024], name[1024];
int c;
@ -143,10 +143,10 @@ static void do_shutdown_exit (void)
}
#ifdef ALLEGRO_MINGW32
static void signal_handler (int num)
static void signal_handler(int num)
{
do_shutdown_exit ();
fprintf (stderr, "Shutting down ASE due to signal #%d\n", num);
raise (num);
do_shutdown_exit();
fprintf(stderr, "Shutting down ASE due to signal #%d\n", num);
raise(num);
}
#endif

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,8 +19,8 @@
#ifndef CORE_SHUTDOWN_H
#define CORE_SHUTDOWN_H
void init_shutdown_handler (void);
void remove_shutdown_handler (void);
void init_shutdown_handler(void);
void remove_shutdown_handler(void);
#endif /* CORE_SHUTDOWN_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -36,9 +36,9 @@
#endif
void GUI_About(void)
void dialogs_about(void)
{
JWidget window, box1, label1, label2, label3, label4, label5;
JWidget window, box1, label1, label2, label3, label4;
JWidget separator1, button1;
if (!is_interactive())
@ -49,15 +49,14 @@ void GUI_About(void)
label1 = jlabel_new("Allegro Sprite Editor - " VERSION);
label2 = jlabel_new(_("The Ultimate Sprites Factory"));
separator1 = ji_separator_new(NULL, JI_HORIZONTAL);
label3 = jlabel_new("Copyright (C) 2001-2005");
label4 = jlabel_new(_("by David A. Capello"));
label5 = jlabel_new("http://ase.sourceforge.net/");
label3 = jlabel_new(COPYRIGHT);
label4 = jlabel_new("http://ase.sourceforge.net/");
button1 = jbutton_new(_("&Close"));
jwidget_magnetic(button1, TRUE);
jwidget_add_childs(box1, label1, label2, separator1,
label3, label4, label5, button1, NULL);
jwidget_add_childs(box1, label1, label2, separator1, label3, label4,
button1, NULL);
jwidget_add_child(window, box1);
jwindow_open_fg(window);

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_ABOUT_H
#define DIALOGS_ABOUT_H
void GUI_About (void);
void dialogs_about(void);
#endif /* DIALOGS_ABOUT_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,7 +35,7 @@
#endif
/* if sprite_frpos < 0, set the frame length of all frames */
void GUI_FrameLength(int sprite_frpos)
void dialogs_frame_length(int sprite_frpos)
{
JWidget window, frpos, frlen, ok;
char buf[64];

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_DFRLEN_H
#define DIALOGS_DFRLEN_H
void GUI_FrameLength(int frpos);
void dialogs_frame_length(int frpos);
#endif /* DIALOGS_DFRLEN_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -58,7 +58,7 @@ static int change_hook (JWidget widget, int user_data);
static JWidget image_viewer_new (Image *image);
static bool image_viewer_msg_proc (JWidget widget, JMessage msg);
void GUI_MapGen (void)
void dialogs_mapgen(void)
{
JWidget window, view_map, check_tiled, button_ok;
Sprite *sprite, *old_sprite = current_sprite;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_DMAPGEN_H
#define DIALOGS_DMAPGEN_H
void GUI_MapGen (void);
void dialogs_mapgen(void);
#endif /* DIALOGS_DMAPGEN_H */

View File

@ -63,7 +63,7 @@ static int palette_editor_change_signal (JWidget widget, int user_data);
static void set_new_palette (RGB *palette);
void show_palette_editor(void)
void dialogs_palette_editor(void)
{
JWidget window, color_viewer_box, palette_editor_view;
JWidget slider_columns, button_ok;

View File

@ -19,7 +19,7 @@
#ifndef DIALOGS_DPALEDIT_H
#define DIALOGS_DPALEDIT_H
void show_palette_editor (void);
void dialogs_palette_editor(void);
#endif /* DIALOGS_DPALEDIT_H */

View File

@ -52,7 +52,7 @@ static FONT *my_load_font(const char *filename);
static void button_font_command(JWidget widget);
static void update_button_text(void);
void GUI_DrawText(void)
void dialogs_draw_text(void)
{
Image *image, *dest_image;
JWidget window, button_ok, color_box, color_but;
@ -175,17 +175,17 @@ Image *RenderText (const char *fontname, int size, int color, const char *text)
static Image *render_text (FONT *f, const char *text, int color)
{
#define DO(type, colfunc) \
{ \
register int c; \
unsigned long *src = bmp->dat; \
type *dst = image->dat; \
for (i=0; i<pixels; i++) { \
c = *src; \
*dst = colfunc; \
src++; \
dst++; \
} \
#define DO(type, colfunc) \
{ \
register int c; \
unsigned long *src = (unsigned long *)bmp->dat; \
type *dst = (type *)image->dat; \
for (i=0; i<pixels; i++) { \
c = *src; \
*dst = colfunc; \
src++; \
dst++; \
} \
}
int i, pixels, w, h;
@ -220,19 +220,19 @@ static Image *render_text (FONT *f, const char *text, int color)
switch (image->imgtype) {
case IMAGE_RGB:
DO (unsigned long, _rgba (_rgba_getr (color),
_rgba_getg (color),
_rgba_getb (color), getg32 (c)));
DO(unsigned long, _rgba(_rgba_getr(color),
_rgba_getg(color),
_rgba_getb(color), getg32(c)));
break;
case IMAGE_GRAYSCALE:
DO (unsigned short, _graya (_graya_getk (color), getg32 (c)));
DO(unsigned short, _graya(_graya_getk(color), getg32(c)));
break;
case IMAGE_INDEXED:
use_current_sprite_rgb_map ();
DO (unsigned char, c == makecol32 (255, 0, 255) ? 0: color);
restore_rgb_map ();
use_current_sprite_rgb_map();
DO(unsigned char, c == makecol32(255, 0, 255) ? 0: color);
restore_rgb_map();
break;
}

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,9 +21,9 @@
struct Image;
void GUI_DrawText (void);
void dialogs_draw_text(void);
struct Image *RenderText (const char *fontname, int size, int color, const char *text);
struct Image *RenderText(const char *fontname, int size, int color, const char *text);
#endif /* DIALOGS_DRAWTEXT_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,10 +19,10 @@
#ifndef DIALOGS_EFFECT_H
#define DIALOGS_EFFECT_H
void GUI_ColorCurve (void);
void GUI_ConvolutionMatrix (void);
void GUI_InvertColor (void);
void GUI_MedianFilter (void);
void GUI_ReplaceColor (void);
void dialogs_color_curve(void);
void dialogs_convolution_matrix(void);
void dialogs_invert_color(void);
void dialogs_median_filter(void);
void dialogs_replace_color(void);
#endif /* DIALOGS_EFFECT_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,7 +49,7 @@ static JWidget check_preview, preview;
static bool hooked_msg_proc (JWidget widget, JMessage msg);
static void make_preview (void);
void GUI_ColorCurve (void)
void dialogs_color_curve(void)
{
JWidget window, button_ok;
JWidget view_curve, curve_editor;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -72,7 +72,7 @@ static int preview_change_hook (JWidget widget, int user_data);
static int tiled_change_hook (JWidget widget, int user_data);
static void make_preview (void);
void GUI_ConvolutionMatrix (void)
void dialogs_convolution_matrix(void)
{
JWidget window, button_ok;
JWidget view_convmatr, list_convmatr;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -53,7 +53,7 @@ static int target_change_hook (JWidget widget, int user_data);
static int preview_change_hook (JWidget widget, int user_data);
static void make_preview (void);
void GUI_InvertColor (void)
void dialogs_invert_color(void)
{
JWidget window, box_target, target_button, button_ok;
Sprite *sprite = current_sprite;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -58,7 +58,7 @@ static int preview_change_hook (JWidget widget, int user_data);
static int tiled_change_hook (JWidget widget, int user_data);
static void make_preview (void);
void GUI_MedianFilter (void)
void dialogs_median_filter(void)
{
JWidget window, box_target, target_button, button_ok;
Image *image;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -57,7 +57,7 @@ static int slider_change_hook (JWidget widget, int user_data);
static int preview_change_hook (JWidget widget, int user_data);
static void make_preview (void);
void GUI_ReplaceColor (void)
void dialogs_replace_color(void)
{
JWidget window, color_buttons_box;
JWidget button1_1, button1_2;

View File

@ -634,7 +634,7 @@ static bool frame_box_msg_proc (JWidget widget, JMessage msg)
/* show the dialog to change the frlen (frame duration time)? */
if (msg->mouse.y < FRMSIZE) {
jwidget_release_mouse (widget);
GUI_FrameLength(current_sprite->frpos);
dialogs_frame_length(current_sprite->frpos);
jwidget_dirty(widget);
return TRUE;
}

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -56,7 +56,7 @@ static int preview_change_hook (JWidget widget, int user_data);
static Mask *gen_mask (void);
static void mask_preview (void);
void GUI_MaskColor (void)
void dialogs_mask_color(void)
{
JWidget window, box1, box2, box3, box4;
JWidget label_color, button_1, button_2;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,6 @@
#ifndef DIALOGS_MASKCOL_H
#define DIALOGS_MASKCOL_H
void GUI_MaskColor (void);
void dialogs_mask_color(void);
#endif /* DIALOGS_MASKCOL_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -49,10 +49,10 @@ static bool use_listitem (RepoDlg *repo_dlg);
static bool add_listitem (RepoDlg *repo_dlg, int *added);
static bool delete_listitem (RepoDlg *repo_dlg, int *kill);
void GUI_MaskRepository (void)
void dialogs_mask_repository(void)
{
RepoDlg repo_dlg = {
"/mask_repository",
"MaskRepository",
_("Mask Repository"),
_("&Replace"),
load_listbox,

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_MASKREPO_H
#define DIALOGS_MASKREPO_H
void GUI_MaskRepository (void);
void dialogs_mask_repository(void);
#endif /* DIALOGS_MASKREPO_H */

View File

@ -33,7 +33,7 @@
#endif
/* show the language selection dialog */
void GUI_SelectLanguage (bool force)
void dialogs_select_language(bool force)
{
bool select_language = get_config_bool ("Options", "SelectLanguage", TRUE);
@ -77,7 +77,7 @@ static void button_lang_command (JWidget widget);
static void set_label_font_text (void);
/* shows option dialog */
void GUI_Options (void)
void dialogs_options(void)
{
JWidget window, move_delay, check_smooth, check_dither;
JWidget button_font, button_lang, button_ok, button_save;
@ -222,12 +222,12 @@ static void button_font_command (JWidget widget)
}
}
static void button_lang_command (JWidget widget)
static void button_lang_command(JWidget widget)
{
GUI_SelectLanguage (TRUE);
dialogs_select_language(TRUE);
}
static void set_label_font_text (void)
static void set_label_font_text(void)
{
const char *default_font = get_config_string ("Options", "DefaultFont", "");
char buf[1024];

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,10 +19,10 @@
#ifndef DIALOGS_OPTIONS_H
#define DIALOGS_OPTIONS_H
void GUI_SelectLanguage (bool force);
void GUI_Options (void);
void dialogs_select_language(bool force);
void dialogs_options(void);
void _setup_mouse_speed (void);
void _setup_mouse_speed(void);
#endif /* DIALOGS_OPTIONS_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -176,12 +176,13 @@ static void my_play_fli (const char *filename, bool loop, bool fullscreen,
}
if (fullscreen)
stretch_blit (bmp, ji_screen,
0, 0, fli_header.width, fli_header.height, x, y, w, h);
stretch_blit(bmp, ji_screen,
0, 0, fli_header.width, fli_header.height, x, y, w, h);
else
blit (bmp, ji_screen, 0, 0, x, y, w, h);
blit(bmp, ji_screen, 0, 0, x, y, w, h);
gui_feedback ();
jmanager_refresh_screen();
gui_feedback();
do {
if ((*callback) ()) {

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,7 +30,7 @@
#endif
void GUI_ScreenSaver (void)
void dialogs_screen_saver(void)
{
int r_value, g_value, b_value;
int r_delta, g_delta, b_delta;
@ -39,17 +39,20 @@ void GUI_ScreenSaver (void)
PALETTE backup;
int c;
if (!is_interactive ())
if (!is_interactive())
return;
/* hide the mouse */
scare_mouse ();
ji_mouse_set_cursor(JI_CURSOR_NULL);
/* get the current color palette */
get_palette (backup);
get_palette(backup);
/* flush drawing messages (useful when we are using double-buffering) */
gui_feedback();
/* clear the screen */
clear (ji_screen);
clear(ji_screen);
/* start the values */
r_value = (rand() & 0x3F);
@ -98,8 +101,8 @@ void GUI_ScreenSaver (void)
v3.y = (rand()%(JI_SCREEN_H+64)) - 32;
/* vertical-retrace */
vsync ();
set_palette_range (palette, 0, PAL_SIZE-1, FALSE);
vsync();
set_palette_range(palette, 0, PAL_SIZE-1, FALSE);
/* colors */
v1.c = palette_color[rand()%256];
@ -107,32 +110,30 @@ void GUI_ScreenSaver (void)
v3.c = palette_color[rand()%256];
/* draw a triangle */
triangle3d_f (ji_screen,
(bitmap_color_depth (ji_screen) == 8)?
POLYTYPE_GCOL: POLYTYPE_GRGB, NULL, &v1, &v2, &v3);
triangle3d_f(ji_screen,
(bitmap_color_depth(ji_screen) == 8)?
POLYTYPE_GCOL: POLYTYPE_GRGB, NULL, &v1, &v2, &v3);
/* poll GUI */
ji_mouse_poll ();
gui_feedback ();
} while ((!keypressed ()) && (!ji_mouse_b (0)));
ji_mouse_poll();
gui_feedback();
} while ((!keypressed()) && (!ji_mouse_b(0)));
/* clear the screen */
clear (ji_screen);
clear(ji_screen);
/* restore the color palette */
set_palette (backup);
/* show the mouse cursor */
unscare_mouse ();
set_palette(backup);
/* wait while the user has pushed some mouse button */
do {
ji_mouse_poll ();
gui_feedback ();
} while (ji_mouse_b (0));
ji_mouse_poll();
gui_feedback();
} while (ji_mouse_b(0));
jmanager_refresh_screen();
ji_mouse_set_cursor(JI_CURSOR_NORMAL);
/* clear again the keyboard buffer */
clear_keybuf ();
jmanager_refresh_screen ();
clear_keybuf();
}

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_SCRSAVER_H
#define DIALOGS_SCRSAVER_H
void GUI_ScreenSaver (void);
void dialogs_screen_saver(void);
#endif /* DIALOGS_SCRSAVER_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -55,7 +55,7 @@ static void prev_command (JWidget widget, void *data);
static void next_command (JWidget widget, void *data);
static int check_signal (JWidget widget, int user_data);
void GUI_Tips (bool forced)
void dialogs_tips(bool forced)
{
JWidget window, vbox, hbox, box;
JWidget button_close, button_prev, button_next;
@ -64,7 +64,7 @@ void GUI_Tips (bool forced)
PALETTE old_pal;
/* don't show it? */
if (!forced && !get_config_bool ("Tips", "Show", TRUE))
if (!forced && !get_config_bool("Tips", "Show", TRUE))
return;
/* next page */
@ -86,79 +86,83 @@ void GUI_Tips (bool forced)
}
}
window = jwindow_new ("Allegro Sprite Editor");
vbox = jbox_new (JI_VERTICAL);
hbox = jbox_new (JI_HORIZONTAL);
box = jbox_new (0);
button_close = jbutton_new (_("&Close"));
button_prev = jbutton_new (_("&Previous"));
button_next = jbutton_new (_("&Next"));
view = jview_new ();
tips = tips_new ();
check = jcheck_new (_("Show me it in the start up"));
window = jwindow_new("Allegro Sprite Editor");
vbox = jbox_new(JI_VERTICAL);
hbox = jbox_new(JI_HORIZONTAL);
box = jbox_new(0);
button_close = jbutton_new(_("&Close"));
button_prev = jbutton_new(_("&Previous"));
button_next = jbutton_new(_("&Next"));
view = jview_new();
tips = tips_new();
check = jcheck_new(_("Show me it in the start up"));
jbutton_add_command_data (button_prev, prev_command, tips);
jbutton_add_command_data (button_next, next_command, tips);
jwidget_set_static_size(button_close, 50, 0);
jwidget_set_static_size(button_prev, 50, 0);
jwidget_set_static_size(button_next, 50, 0);
HOOK (check, JI_SIGNAL_CHECK_CHANGE, check_signal, 0);
jbutton_add_command_data(button_prev, prev_command, tips);
jbutton_add_command_data(button_next, next_command, tips);
if (get_config_bool ("Tips", "Show", TRUE))
jwidget_select (check);
HOOK(check, JI_SIGNAL_CHECK_CHANGE, check_signal, 0);
jview_attach (view, tips);
if (get_config_bool("Tips", "Show", TRUE))
jwidget_select(check);
jwidget_expansive (view, TRUE);
jwidget_expansive (box, TRUE);
jview_attach(view, tips);
jwidget_add_child (vbox, view);
jwidget_add_child (hbox, button_close);
jwidget_add_child (box, check);
jwidget_add_child (hbox, box);
jwidget_add_child (hbox, button_prev);
jwidget_add_child (hbox, button_next);
jwidget_add_child (vbox, hbox);
jwidget_add_child (window, vbox);
jwidget_expansive(view, TRUE);
jwidget_expansive(box, TRUE);
jwidget_add_child(vbox, view);
jwidget_add_child(hbox, button_close);
jwidget_add_child(box, check);
jwidget_add_child(hbox, box);
jwidget_add_child(hbox, button_prev);
jwidget_add_child(hbox, button_next);
jwidget_add_child(vbox, hbox);
jwidget_add_child(window, vbox);
if (JI_SCREEN_W > 320)
jwidget_set_static_size (window,
MIN (400, JI_SCREEN_W-32),
MIN (300, JI_SCREEN_H-32));
jwidget_set_static_size(window,
MIN(400, JI_SCREEN_W-32),
MIN(300, JI_SCREEN_H-32));
else
jwidget_set_static_size (window, 282, 182);
jwidget_set_static_size(window, 282, 182);
/* open the window */
jwindow_open (window);
jwidget_set_static_size (window, 0, 0);
jwindow_open(window);
jwidget_set_static_size(window, 0, 0);
/* load first page */
memcpy (old_pal, current_palette, sizeof (PALETTE));
tips_load_page (tips);
memcpy(old_pal, current_palette, sizeof (PALETTE));
tips_load_page(tips);
/* run the window */
jwindow_open_fg (window);
jwidget_free (window);
jwindow_open_fg(window);
jwidget_free(window);
/* restore the palette */
set_current_palette (old_pal, TRUE);
jmanager_refresh_screen ();
set_current_palette(old_pal, TRUE);
jmanager_refresh_screen();
}
/***********************************************************************
Tips
***********************************************************************/
static JWidget tips_new (void)
static JWidget tips_new(void)
{
JWidget widget = jwidget_new (tips_type ());
JWidget widget = jwidget_new(tips_type());
jwidget_add_hook (widget, tips_type (), tips_msg_proc, NULL);
jwidget_focusrest (widget, TRUE);
jwidget_noborders (widget);
jwidget_add_hook(widget, tips_type(), tips_msg_proc, NULL);
jwidget_focusrest(widget, TRUE);
jwidget_noborders(widget);
return widget;
}
static int tips_type (void)
static int tips_type(void)
{
static int type = 0;
if (!type)
@ -166,13 +170,28 @@ static int tips_type (void)
return type;
}
static bool tips_msg_proc (JWidget widget, JMessage msg)
static bool tips_msg_proc(JWidget widget, JMessage msg)
{
switch (msg->type) {
case JM_REQSIZE:
tips_request_size (widget, &msg->reqsize.w, &msg->reqsize.h);
return TRUE;
case JM_WHEEL:
{
JWidget view = jwidget_get_view(widget);
JRect vp = jview_get_viewport_position(view);
int dz = ji_mouse_z(1) - ji_mouse_z(0);
int scroll_x, scroll_y;
jview_get_scroll(view, &scroll_x, &scroll_y);
jview_set_scroll(view, scroll_x, scroll_y + dz * jrect_h(vp)/3);
jrect_free(vp);
}
break;
}
return FALSE;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_TIPS_H
#define DIALOGS_TIPS_H
void GUI_Tips (bool forced);
void dialogs_tips(bool forced);
#endif /* DIALOGS_TIPS_H */

View File

@ -62,7 +62,7 @@ static int set_grid_button_select_hook(JWidget widget, int user_data);
static int cursor_button_change_hook(JWidget widget, int user_data);
static int onionskin_check_change_hook(JWidget widget, int user_data);
void GUI_ToolsConfiguration(void)
void dialogs_tools_configuration(void)
{
JWidget filled, tiled, use_grid, view_grid, set_grid;
JWidget brush_size, brush_angle, glass_dirty;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,7 +19,7 @@
#ifndef DIALOGS_TOOLCONF_H
#define DIALOGS_TOOLCONF_H
void GUI_ToolsConfiguration (void);
void dialogs_tools_configuration(void);
#endif /* DIALOGS_TOOLCONF_H */

View File

@ -127,7 +127,7 @@ static int image_getpixel4 (Image *image, double x, double y)
return bilinear4 (a, b, c, d, ftofix (x), ftofix (y));
}
void GUI_VectorMap (void)
void dialogs_vector_map(void)
{
#define PROJECT() project (image, x, y, dmax, &u, &v)

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,6 @@
#ifndef DIALOGS_VECTMAP_H
#define DIALOGS_VECTMAP_H
void GUI_VectorMap (void);
void dialogs_vector_map(void);
#endif /* DIALOGS_VECTMAP_H */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -63,13 +63,13 @@ static void view_sprite(int flags)
JRect vp;
int bg_color, index_bg_color = -1;
jmanager_free_mouse ();
jmanager_free_mouse();
vp = jview_get_viewport_position (view);
jview_get_scroll (view, &scroll_x, &scroll_y);
vp = jview_get_viewport_position(view);
jview_get_scroll(view, &scroll_x, &scroll_y);
old_mouse_x = ji_mouse_x (0);
old_mouse_y = ji_mouse_y (0);
old_mouse_x = ji_mouse_x(0);
old_mouse_y = ji_mouse_y(0);
bmp = create_bitmap (sprite->w, sprite->h);
if (bmp) {

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -51,8 +51,8 @@ static struct {
static PALETTE file_palette;
static char file_extensions[512];
static FileType *get_filetype (const char *extension);
static int split_filename (const char *filename, char *left, char *right, int *width);
static FileType *get_filetype(const char *extension);
static int split_filename(const char *filename, char *left, char *right, int *width);
void file_sequence_set_color(int index, int r, int g, int b)
{
@ -68,7 +68,7 @@ void file_sequence_get_color(int index, int *r, int *g, int *b)
*b = file_palette[index].b;
}
Image *file_sequence_image (int imgtype, int w, int h)
Image *file_sequence_image(int imgtype, int w, int h)
{
Sprite *sprite;
Image *image;
@ -76,20 +76,20 @@ Image *file_sequence_image (int imgtype, int w, int h)
/* create the image */
if (!file_sequence.sprite) {
sprite = sprite_new (imgtype, w, h);
sprite = sprite_new(imgtype, w, h);
if (!sprite)
return NULL;
layer = layer_new (imgtype);
layer = layer_new(imgtype);
if (!layer) {
sprite_free (sprite);
sprite_free(sprite);
return NULL;
}
layer_set_name (layer, _("Background"));
layer_set_name(layer, _("Background"));
/* add the layer */
layer_add_layer (sprite->set, layer);
layer_add_layer(sprite->set, layer);
/* done */
file_sequence.sprite = sprite;
@ -105,13 +105,13 @@ Image *file_sequence_image (int imgtype, int w, int h)
/* create a bitmap */
if (file_sequence.last_frame) {
console_printf (_("Error: called two times \"file_sequence_image ()\".\n"));
console_printf(_("Error: called two times \"file_sequence_image ()\".\n"));
return NULL;
}
image = image_new (imgtype, w, h);
if (!image) {
console_printf (_("Not enough memory to allocate a bitmap.\n"));
console_printf(_("Not enough memory to allocate a bitmap.\n"));
return NULL;
}
@ -121,17 +121,17 @@ Image *file_sequence_image (int imgtype, int w, int h)
return image;
}
Sprite *file_sequence_sprite (void)
Sprite *file_sequence_sprite(void)
{
return file_sequence.sprite;
}
Image *file_sequence_image_to_save (void)
Image *file_sequence_image_to_save(void)
{
return file_sequence.image;
}
const char *get_readable_extensions (void)
const char *get_readable_extensions(void)
{
int c;
@ -150,7 +150,7 @@ const char *get_readable_extensions (void)
return file_extensions;
}
const char *get_writeable_extensions (void)
const char *get_writeable_extensions(void)
{
int c;
@ -169,7 +169,7 @@ const char *get_writeable_extensions (void)
return file_extensions;
}
Sprite *sprite_load (const char *filename)
Sprite *sprite_load(const char *filename)
{
char extension[32];
FileType *file;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -89,13 +89,13 @@ static Sprite *load_FLI(const char *filename)
h = fli_header.height;
/* create the bitmaps */
bmp = image_new (IMAGE_INDEXED, w, h);
old = image_new (IMAGE_INDEXED, w, h);
bmp = image_new(IMAGE_INDEXED, w, h);
old = image_new(IMAGE_INDEXED, w, h);
if ((!bmp) || (!old)) {
console_printf (_("Not enough memory for temporary bitmaps.\n"));
if (bmp) image_free (bmp);
if (old) image_free (old);
fclose (f);
console_printf(_("Not enough memory for temporary bitmaps.\n"));
if (bmp) image_free(bmp);
if (old) image_free(old);
fclose(f);
return NULL;
}

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -324,6 +324,9 @@ static int save_GIF(Sprite *sprite)
gif->frames[i].transparent_index = 0;
}
/* avoid compilation warnings */
x1 = y1 = x2 = y2 = 0;
for (i = 0; i < sprite->frames; i++) {
/* frame palette */
palette_copy(npal, sprite_get_palette(sprite, i));

View File

@ -1,3 +1,5 @@
#include <allegro.h>
#include "format.h"
#include "lzw.h"
@ -390,7 +392,13 @@ gif_load_animation (const char *filename, void (*progress) (int))
{
PACKFILE *file;
GIF_ANIMATION *gif = NULL;
int size = file_size (filename);
#if (MAKE_VERSION(4, 2, 0) < MAKE_VERSION(ALLEGRO_VERSION, \
ALLEGRO_SUB_VERSION, \
ALLEGRO_WIP_VERSION))
int size = file_size(filename);
#else
int size = file_size_ex(filename);
#endif
file = pack_fopen (filename, "r");
if (file)

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,6 +24,7 @@ extern FileType filetype_pcx;
extern FileType filetype_tga;
extern FileType filetype_gif;
extern FileType filetype_ico;
extern FileType filetype_png;
static FileType *filetypes[] =
{
@ -35,5 +36,6 @@ static FileType *filetypes[] =
&filetype_tga,
&filetype_gif,
&filetype_ico,
&filetype_png,
NULL
};

691
src/file/png_file.c Normal file
View File

@ -0,0 +1,691 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#ifndef USE_PRECOMPILED_HEADER
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include "console/console.h"
#include "core/app.h"
#include "core/cfg.h"
#include "core/core.h"
#include "file/file.h"
#include "raster/raster.h"
#include "script/script.h"
#include "png.h"
#endif
static Sprite *load_png(const char *filename);
static int save_png(Sprite *sprite);
/* static int configure_png(void); */
FileType filetype_png =
{
"png",
"png",
load_png,
save_png,
FILE_SUPPORT_RGB |
FILE_SUPPORT_RGBA |
FILE_SUPPORT_GRAY |
FILE_SUPPORT_GRAYA |
FILE_SUPPORT_INDEXED |
FILE_SUPPORT_SEQUENCES
};
/* static void progress_monitor(j_common_ptr cinfo) */
/* { */
/* if (cinfo->progress->pass_limit > 1) */
/* do_progress(100 * */
/* (cinfo->progress->pass_counter) / */
/* (cinfo->progress->pass_limit-1)); */
/* } */
/* struct error_mgr { */
/* struct jpeg_error_mgr pub; */
/* jmp_buf setjmp_buffer; */
/* }; */
/* static void error_exit(j_common_ptr cinfo) */
/* { */
/* /\* Display the message. *\/ */
/* (*cinfo->err->output_message)(cinfo); */
/* /\* Return control to the setjmp point. *\/ */
/* longjmp(((struct error_mgr *)cinfo->err)->setjmp_buffer, 1); */
/* } */
/* static void output_message(j_common_ptr cinfo) */
/* { */
/* char buffer[JMSG_LENGTH_MAX]; */
/* /\* Format the message. *\/ */
/* (*cinfo->err->format_message)(cinfo, buffer); */
/* /\* Put in the log file if. *\/ */
/* PRINTF("JPEG library: \"%s\"\n", buffer); */
/* /\* Leave the message for the application. *\/ */
/* console_printf("%s\n", buffer); */
/* } */
static void report_png_error(png_structp png_ptr, png_const_charp error)
{
console_printf("libpng: %s\n", error);
}
static Sprite *load_png(const char *filename)
{
png_uint_32 width, height, y;
unsigned int sig_read = 0;
png_structp png_ptr;
png_infop info_ptr;
int bit_depth, color_type, interlace_type;
int intent, screen_gamma;
int max_screen_colors = 256;
/* int pass, number_passes; */
png_bytep row_pointer;
Image *image;
int imgtype;
FILE *fp;
fp = fopen(filename, "rb");
if (!fp) {
if (!file_sequence_sprite())
console_printf(_("Error opening file.\n"));
return NULL;
}
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also supply the
* the compiler header file version, so that we know if the application
* was compiled with a compatible version of the library
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
report_png_error, report_png_error);
if (png_ptr == NULL) {
console_printf("png_create_read_struct\n");
fclose(fp);
return NULL;
}
/* Allocate/initialize the memory for image information. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
console_printf("png_create_info_struct\n");
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return NULL;
}
/* Set error handling if you are using the setjmp/longjmp method (this is
* the normal method of doing things with libpng).
*/
if (setjmp(png_jmpbuf(png_ptr))) {
console_printf("Error reading PNG file\n");
/* Free all of the memory associated with the png_ptr and info_ptr */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
/* If we get here, we had a problem reading the file */
return NULL;
}
/* Set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
/* If we have already read some of the signature */
png_set_sig_bytes(png_ptr, sig_read);
/* The call to png_read_info() gives us all of the information from the
* PNG file before the first IDAT (image data chunk).
*/
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, int_p_NULL, int_p_NULL);
/* Set up the data transformations you want. Note that these are all
* optional. Only call them if you want/need them. Many of the
* transformations only work on specific types of images, and many
* are mutually exclusive.
*/
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
/* png_set_strip_alpha(png_ptr); */
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
png_set_packing(png_ptr);
/* Change the order of packed pixels to least significant bit first
* (not useful if you are using png_set_packing). */
/* png_set_packswap(png_ptr); */
/* Expand paletted colors into true RGB triplets */
/* if (color_type == PNG_COLOR_TYPE_PALETTE) */
/* png_set_palette_to_rgb(png_ptr); */
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
png_set_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets.
*/
/* if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) */
/* png_set_tRNS_to_alpha(png_ptr); */
/* Set the background color to draw transparent and alpha images over.
* It is possible to set the red, green, and blue components directly
* for paletted images instead of supplying a palette index. Note that
* even if the PNG file supplies a background, you are not required to
* use it - you should use the (solid) application background if it has one.
*/
/* png_color_16 my_background, *image_background; */
/* if (png_get_bKGD(png_ptr, info_ptr, &image_background)) */
/* png_set_background(png_ptr, image_background, */
/* PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); */
/* else */
/* png_set_background(png_ptr, &my_background, */
/* PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); */
/* Some suggestions as to how to get a screen gamma value */
/* Note that screen gamma is the display_exponent, which includes
* the CRT_exponent and any correction for viewing conditions */
/* screen_gamma = 2.2; /\* A good guess for a PC monitors in a dimly lit room *\/ */
/* screen_gamma = 1.7 or 1.0; /\* A good guess for Mac systems *\/ */
screen_gamma = 2.2;
/* Tell libpng to handle the gamma conversion for you. The final call
* is a good guess for PC generated images, but it should be configurable
* by the user at run time by the user. It is strongly suggested that
* your application support gamma correction.
*/
/* if (png_get_sRGB(png_ptr, info_ptr, &intent)) */
/* png_set_gamma(png_ptr, screen_gamma, 0.45455); */
/* else { */
/* double image_gamma; */
/* if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) */
/* png_set_gamma(png_ptr, screen_gamma, image_gamma); */
/* else */
/* png_set_gamma(png_ptr, screen_gamma, 0.45455); */
/* } */
/* Dither RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
*/
/* if (color_type & PNG_COLOR_MASK_COLOR) { */
/* int num_palette; */
/* png_colorp palette; */
/* /\* This reduces the image to the application supplied palette *\/ */
/* /\* if (/\\* we have our own palette *\\/) *\/ */
/* /\* { *\/ */
/* /\* /\\* An array of colors to which the image should be dithered *\\/ *\/ */
/* /\* png_color std_color_cube[MAX_SCREEN_COLORS]; *\/ */
/* /\* png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, *\/ */
/* /\* MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); *\/ */
/* /\* } *\/ */
/* /\* This reduces the image to the palette supplied in the file *\/ */
/* /\* else *\/ */
/* if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) */
/* { */
/* png_uint_16p histogram = NULL; */
/* png_get_hIST(png_ptr, info_ptr, &histogram); */
/* png_set_dither(png_ptr, palette, num_palette, */
/* max_screen_colors, histogram, 0); */
/* } */
/* } */
/* invert monochrome files to have 0 as white and 1 as black */
/* png_set_invert_mono(png_ptr); */
/* If you want to shift the pixel values from the range [0,255] or
* [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
/* if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) { */
/* png_color_8p sig_bit; */
/* png_get_sBIT(png_ptr, info_ptr, &sig_bit); */
/* png_set_shift(png_ptr, sig_bit); */
/* } */
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
/* if (color_type & PNG_COLOR_MASK_COLOR) */
/* png_set_bgr(png_ptr); */
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
/* png_set_swap_alpha(png_ptr); */
/* swap bytes of 16 bit files to least significant byte first */
/* png_set_swap(png_ptr); */
/* Add filler (or alpha) byte (before/after each RGB triplet) */
/* png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); */
/* Turn on interlace handling. REQUIRED if you are not using
* png_read_image(). To see how to handle interlacing passes,
* see the png_read_row() method below:
*/
/* number_passes = png_set_interlace_handling(png_ptr); */
/* Optional call to gamma correct and add the background to the palette
* and update info structure.
*/
png_read_update_info(png_ptr, info_ptr);
/* create the output image */
switch (info_ptr->color_type) {
case PNG_COLOR_TYPE_GRAY:
case PNG_COLOR_TYPE_GRAY_ALPHA:
imgtype = IMAGE_GRAYSCALE;
break;
case PNG_COLOR_TYPE_PALETTE:
imgtype = IMAGE_INDEXED;
break;
case PNG_COLOR_TYPE_RGB:
case PNG_COLOR_TYPE_RGB_ALPHA:
imgtype = IMAGE_RGB;
break;
default:
console_printf("Color type not supported\n)");
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
return NULL;
}
image = file_sequence_image(imgtype, info_ptr->width, info_ptr->height);
if (!image) {
console_printf("file_sequence_image %dx%d\n", info_ptr->width, info_ptr->height);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
return NULL;
}
/* Allocate the memory to hold the image using the fields of info_ptr. */
/* The easiest way to read the image: */
row_pointer = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
/* for (pass = 0; pass < number_passes; pass++) { */
for (y = 0; y < height; y++) {
png_read_row(png_ptr, row_pointer, png_bytepp_NULL);
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
unsigned char *src_address = row_pointer;
unsigned long *dst_address = ((unsigned long **)image->line)[y];
int x, r, g, b, a;
for (x=0; x<width; x++) {
r = *(src_address++);
g = *(src_address++);
b = *(src_address++);
a = *(src_address++);
*(dst_address++) = _rgba(r, g, b, a);
}
}
else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) {
unsigned char *src_address = row_pointer;
unsigned long *dst_address = ((unsigned long **)image->line)[y];
int x, y, r, g, b;
for (x=0; x<width; x++) {
r = *(src_address++);
g = *(src_address++);
b = *(src_address++);
*(dst_address++) = _rgba(r, g, b, 255);
}
}
do_progress(100 * y / height);
}
/* } */
png_free(png_ptr, row_pointer);
/* read rest of file, and get additional chunks in info_ptr */
/* png_read_end(png_ptr, info_ptr); */
/* clean up after the read, and free any memory allocated */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
/* close the file */
fclose(fp);
/* return the sprite */
return file_sequence_sprite();
#if 0
struct jpeg_decompress_struct cinfo;
struct error_mgr jerr;
struct jpeg_progress_mgr progress;
Image *image;
JDIMENSION num_scanlines;
JSAMPARRAY buffer;
JDIMENSION buffer_height;
int c;
/* initialize the JPEG decompression object with error handling */
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = error_exit;
jerr.pub.output_message = output_message;
/* establish the setjmp return context for error_exit to use */
if (setjmp(jerr.setjmp_buffer)) {
jpeg_destroy_decompress(&cinfo);
fclose(file);
return NULL;
}
jpeg_create_decompress(&cinfo);
/* specify data source for decompression */
jpeg_stdio_src(&cinfo, file);
/* read file header, set default decompression parameters */
jpeg_read_header(&cinfo, TRUE);
if (cinfo.jpeg_color_space == JCS_GRAYSCALE)
cinfo.out_color_space = JCS_GRAYSCALE;
else
cinfo.out_color_space = JCS_RGB;
/* start decompressor */
jpeg_start_decompress(&cinfo);
/* create the image */
image = file_sequence_image((cinfo.out_color_space == JCS_RGB ? IMAGE_RGB:
IMAGE_GRAYSCALE),
cinfo.output_width,
cinfo.output_height);
if (!image) {
jpeg_destroy_decompress(&cinfo);
fclose(file);
return NULL;
}
/* create the buffer */
buffer_height = cinfo.rec_outbuf_height;
buffer = jmalloc(sizeof(JSAMPROW) * buffer_height);
if (!buffer) {
jpeg_destroy_decompress(&cinfo);
fclose(file);
return NULL;
}
for (c=0; c<(int)buffer_height; c++) {
buffer[c] = jmalloc(sizeof(JSAMPLE) *
cinfo.output_width * cinfo.output_components);
if (!buffer[c]) {
for (c--; c>=0; c--)
jfree(buffer[c]);
jfree(buffer);
jpeg_destroy_decompress(&cinfo);
fclose(file);
return NULL;
}
}
/* generate a grayscale palette if is necessary */
if (image->imgtype == IMAGE_GRAYSCALE)
for (c=0; c<256; c++)
file_sequence_set_color(c, c >> 2, c >> 2, c >> 2);
/* for progress bar */
progress.progress_monitor = progress_monitor;
cinfo.progress = &progress;
/* read each scan line */
while (cinfo.output_scanline < cinfo.output_height) {
/* if (plugin_want_close()) */
/* break; */
num_scanlines = jpeg_read_scanlines(&cinfo, buffer, buffer_height);
/* RGB */
if (image->imgtype == IMAGE_RGB) {
unsigned char *src_address;
unsigned long *dst_address;
int x, y, r, g, b;
for (y=0; y<(int)num_scanlines; y++) {
src_address = ((unsigned char **)buffer)[y];
dst_address = ((unsigned long **)image->line)[cinfo.output_scanline-1+y];
for (x=0; x<image->w; x++) {
r = *(src_address++);
g = *(src_address++);
b = *(src_address++);
*(dst_address++) = _rgba (r, g, b, 255);
}
}
}
/* Grayscale */
else {
unsigned char *src_address;
unsigned short *dst_address;
int x, y;
for (y=0; y<(int)num_scanlines; y++) {
src_address = ((unsigned char **)buffer)[y];
dst_address = ((unsigned short **)image->line)[cinfo.output_scanline-1+y];
for (x=0; x<image->w; x++)
*(dst_address++) = _graya(*(src_address++), 255);
}
}
}
/* destroy all data */
for (c=0; c<(int)buffer_height; c++)
jfree(buffer[c]);
jfree(buffer);
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(file);
return file_sequence_sprite();
#endif
}
static int save_png(Sprite *sprite)
{
#if 0
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
struct jpeg_progress_mgr progress;
FILE *file;
JSAMPARRAY buffer;
JDIMENSION buffer_height;
Image *image;
int c;
int smooth;
int quality;
J_DCT_METHOD method;
/* Configure JPEG compression only in the first frame. */
if (sprite->frpos == 0 && configure_jpeg() < 0)
return 0;
/* Options. */
smooth = get_config_int("JPEG", "Smooth", 0);
quality = get_config_int("JPEG", "Quality", 100);
method = get_config_int("JPEG", "Method", JDCT_DEFAULT);
/* Open the file for write in it. */
file = fopen(sprite->filename, "wb");
if (!file) {
console_printf(_("Error creating file.\n"));
return -1;
}
image = file_sequence_image_to_save();
/* Allocate and initialize JPEG compression object. */
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
/* Specify data destination file. */
jpeg_stdio_dest(&cinfo, file);
/* Set parameters for compression. */
cinfo.image_width = image->w;
cinfo.image_height = image->h;
if (image->imgtype == IMAGE_GRAYSCALE) {
cinfo.input_components = 1;
cinfo.in_color_space = JCS_GRAYSCALE;
}
else {
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
}
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE);
cinfo.dct_method = method;
cinfo.smoothing_factor = smooth;
/* Start compressor. */
jpeg_start_compress(&cinfo, TRUE);
/* Create the buffer. */
buffer_height = 1;
buffer = jmalloc(sizeof(JSAMPROW) * buffer_height);
if (!buffer) {
console_printf(_("Not enough memory for the buffer.\n"));
jpeg_destroy_compress(&cinfo);
fclose(file);
return -1;
}
for (c=0; c<(int)buffer_height; c++) {
buffer[c] = jmalloc(sizeof(JSAMPLE) *
cinfo.image_width * cinfo.num_components);
if (!buffer[c]) {
console_printf(_("Not enough memory for buffer scanlines.\n"));
for (c--; c>=0; c--)
jfree(buffer[c]);
jfree(buffer);
jpeg_destroy_compress(&cinfo);
fclose(file);
return -1;
}
}
/* For progress bar. */
progress.progress_monitor = progress_monitor;
cinfo.progress = &progress;
/* Write each scan line. */
while (cinfo.next_scanline < cinfo.image_height) {
/* RGB */
if (image->imgtype == IMAGE_RGB) {
unsigned long *src_address;
unsigned char *dst_address;
int x, y;
for (y=0; y<(int)buffer_height; y++) {
src_address = ((unsigned long **)image->line)[cinfo.next_scanline+y];
dst_address = ((unsigned char **)buffer)[y];
for (x=0; x<image->w; x++) {
c = *(src_address++);
*(dst_address++) = _rgba_getr(c);
*(dst_address++) = _rgba_getg(c);
*(dst_address++) = _rgba_getb(c);
}
}
}
/* Grayscale */
else {
unsigned short *src_address;
unsigned char *dst_address;
int x, y;
for (y=0; y<(int)buffer_height; y++) {
src_address = ((unsigned short **)image->line)[cinfo.next_scanline+y];
dst_address = ((unsigned char **)buffer)[y];
for (x=0; x<image->w; x++)
*(dst_address++) = _graya_getk(*(src_address++));
}
}
jpeg_write_scanlines(&cinfo, buffer, buffer_height);
}
/* Destroy all data. */
for (c=0; c<(int)buffer_height; c++)
jfree(buffer[c]);
jfree(buffer);
/* Finish compression. */
jpeg_finish_compress(&cinfo);
/* Release JPEG compression object. */
jpeg_destroy_compress(&cinfo);
/* We can close the output file. */
fclose(file);
/* All fine. */
return 0;
#else
return -1;
#endif
}
/* static int configure_jpeg(void) */
/* { */
/* /\* interactive mode *\/ */
/* if (is_interactive()) { */
/* lua_State *L = get_lua_state(); */
/* int ret; */
/* /\* call the ConfigureJPEG() script routine, it must return "true" */
/* to save the image *\/ */
/* lua_pushstring(L, "ConfigureJPEG"); */
/* lua_gettable(L, LUA_GLOBALSINDEX); */
/* do_script_raw(L, 0, 1); */
/* ret = lua_toboolean(L, -1); */
/* lua_pop(L, 1); */
/* if (!ret) */
/* return -1; */
/* } */
/* return 0; */
/* } */

View File

@ -345,19 +345,19 @@ static Sprite *load_TGA (const char *filename)
case 2:
if (bpp == 32) {
if (compressed) {
rle_tga_read32 (image->line[yc], image_width, f);
rle_tga_read32(image->line[yc], image_width, f);
}
else {
for (x=0; x<image_width; x++) {
pack_fread(rgb, 4, f);
*(((unsigned long **)image->line)[yc]+x) =
_rgba (rgb[2], rgb[1], rgb[0], rgb[3]);
_rgba(rgb[2], rgb[1], rgb[0], rgb[3]);
}
}
}
else if (bpp == 24) {
if (compressed) {
rle_tga_read24 (image->line[yc], image_width, f);
rle_tga_read24(image->line[yc], image_width, f);
}
else {
for (x=0; x<image_width; x++) {

View File

@ -29,7 +29,7 @@
/* Information for "ident". */
const char ase_ident[] =
"$ASE: " VERSION " Copyright (C) 2001-2005, 2007 David A. Capello $\n"
"$ASE: " VERSION " " COPYRIGHT " $\n"
"$Date: 2007/09/09 03:37:55 $\n"
"$Website: " WEBSITE " $\n";

View File

@ -318,27 +318,27 @@ static bool method_tool_rectangle (JWidget menuitem)
return TRUE;
}
static bool method_tool_ellipse (JWidget menuitem)
static bool method_tool_ellipse(JWidget menuitem)
{
if (current_tool == &ase_tool_ellipse)
jwidget_select (menuitem);
jwidget_select(menuitem);
else
jwidget_deselect (menuitem);
jwidget_deselect(menuitem);
return TRUE;
}
static bool method_is_rec (JWidget menuitem)
static bool method_is_rec(JWidget menuitem)
{
if (is_rec_screen ())
jwidget_select (menuitem);
if (is_rec_screen())
jwidget_select(menuitem);
else
jwidget_deselect (menuitem);
jwidget_deselect(menuitem);
return TRUE;
}
static bool method_is_movingframe (JWidget menuitem)
static bool method_is_movingframe(JWidget menuitem)
{
return is_movingframe ();
}

View File

@ -16,8 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* #define GUI_DOUBLE_BUFFERED */
#include "config.h"
#ifndef USE_PRECOMPILED_HEADER
@ -51,16 +49,31 @@
#endif
#define GUI_DEFAULT_WIDTH 640
#define GUI_DEFAULT_HEIGHT 480
#define GUI_DEFAULT_DEPTH 8
#define GUI_DEFAULT_FULLSCREEN FALSE
#define GUI_DEFAULT_SCALE 2
#define REBUILD_LOCK 1
#define REBUILD_ROOT_MENU 2
#define REBUILD_SPRITE_LIST 4
#define REBUILD_RECENT_LIST 8
#define REBUILD_FULLREFRESH 16
static JWidget manager = NULL;
static int next_idle_flags = 0;
static JList icon_buttons;
/* default GUI screen configuration */
static bool double_buffering;
static int screen_scaling;
/* load & save graphics configuration */
static void load_gui_config(int *w, int *h, int *bpp, bool *fullscreen);
static void save_gui_config(void);
static bool button_with_icon_msg_proc(JWidget widget, JMessage msg);
static bool manager_msg_proc(JWidget widget, JMessage msg);
@ -71,7 +84,7 @@ static void regen_theme_and_fixup_icons(void);
*/
static void display_switch_in_callback()
{
GUI_Refresh(current_sprite);
next_idle_flags |= REBUILD_FULLREFRESH;
}
/**
@ -111,29 +124,38 @@ int init_module_gui(void)
autodetect = fullscreen ? GFX_AUTODETECT_FULLSCREEN:
GFX_AUTODETECT_WINDOWED;
if (!w) w = DEFAULT_GFX_WIDTH;
if (!h) h = DEFAULT_GFX_HEIGHT;
if (!w) w = GUI_DEFAULT_WIDTH;
if (!h) h = GUI_DEFAULT_HEIGHT;
if (!bpp) {
bpp = desktop_color_depth();
if (!bpp)
bpp = DEFAULT_GFX_DEPTH;
bpp = GUI_DEFAULT_DEPTH;
}
/* try original mode */
set_color_depth(bpp);
if (set_gfx_mode(autodetect, w, h, 0, 0) < 0) {
/* try the same resolution but with 8 bpp */
set_color_depth(bpp = 8);
while (screen_scaling > 0) {
/* try original mode */
set_color_depth(bpp);
if (set_gfx_mode(autodetect, w, h, 0, 0) < 0) {
/* try 320x200 in 8 bpp */
if (set_gfx_mode(autodetect, w = 320, h = 200, 0, 0) < 0) {
user_printf(_("Error setting graphics mode\n%s\n"
"Try \"ase -res WIDTHxHEIGHTxBPP\"\n"), allegro_error);
return -1;
}
}
/* try the same resolution but with 8 bpp */
set_color_depth(bpp = 8);
if (set_gfx_mode(autodetect, w, h, 0, 0) < 0) {
/* try 320x200 in 8 bpp */
if (set_gfx_mode(autodetect, w = 320, h = 200, 0, 0) < 0) {
if (screen_scaling == 1) {
user_printf(_("Error setting graphics mode\n%s\n"
"Try \"ase -res WIDTHxHEIGHTxBPP\"\n"), allegro_error);
return -1;
}
else
--screen_scaling;
} else break;
} else break;
} else break;
}
/* double buffering is required when screen scaling is used */
double_buffering = (screen_scaling > 1);
/* create the default-manager */
manager = jmanager_new();
jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL);
@ -171,12 +193,12 @@ int init_module_gui(void)
void exit_module_gui(void)
{
#ifdef GUI_DOUBLE_BUFFERED
BITMAP *old_bmp = ji_screen;
ji_set_screen(screen);
if (old_bmp && old_bmp != screen)
destroy_bitmap(old_bmp);
#endif
if (double_buffering) {
BITMAP *old_bmp = ji_screen;
ji_set_screen(screen);
if (old_bmp && old_bmp != screen)
destroy_bitmap(old_bmp);
}
jlist_free(icon_buttons);
@ -190,20 +212,23 @@ void exit_module_gui(void)
remove_timer();
}
void load_gui_config(int *w, int *h, int *bpp, bool *fullscreen)
static void load_gui_config(int *w, int *h, int *bpp, bool *fullscreen)
{
*w = get_config_int("GfxMode", "Width", 0);
*h = get_config_int("GfxMode", "Height", 0);
*bpp = get_config_int("GfxMode", "Depth", 0);
*fullscreen = get_config_bool("GfxMode", "FullScreen", TRUE);
*fullscreen = get_config_bool("GfxMode", "FullScreen", GUI_DEFAULT_FULLSCREEN);
screen_scaling = get_config_int("GfxMode", "Scale", GUI_DEFAULT_SCALE);
screen_scaling = MAX(1, screen_scaling);
}
void save_gui_config(void)
static void save_gui_config(void)
{
set_config_int("GfxMode", "Width", JI_SCREEN_W);
set_config_int("GfxMode", "Height", JI_SCREEN_H);
set_config_int("GfxMode", "Width", SCREEN_W);
set_config_int("GfxMode", "Height", SCREEN_H);
set_config_int("GfxMode", "Depth", bitmap_color_depth(screen));
set_config_bool("GfxMode", "FullScreen", gfx_driver->windowed ? FALSE: TRUE);
set_config_int("GfxMode", "Scale", screen_scaling);
}
void GUI_Refresh(Sprite *sprite)
@ -223,9 +248,9 @@ void GUI_Refresh(Sprite *sprite)
}
}
void run_gui(void)
void gui_run(void)
{
jmanager_run (manager);
jmanager_run(manager);
}
void gui_feedback(void)
@ -249,21 +274,30 @@ void gui_feedback(void)
next_idle_flags ^= REBUILD_RECENT_LIST;
app_realloc_recent_list();
}
if (next_idle_flags & REBUILD_FULLREFRESH) {
next_idle_flags ^= REBUILD_FULLREFRESH;
GUI_Refresh(current_sprite);
}
}
/* record file if is necessary */
rec_screen_poll();
#ifdef GUI_DOUBLE_BUFFERED
if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) {
blit(ji_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
/* double buffering? */
if (double_buffering) {
jmanager_dispatch_draw_messages();
ji_mouse_draw_cursor();
if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) {
blit(ji_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
else {
stretch_blit(ji_screen, screen,
0, 0, ji_screen->w, ji_screen->h,
0, 0, SCREEN_W, SCREEN_H);
}
}
else {
stretch_blit(ji_screen, screen,
0, 0, ji_screen->w, ji_screen->h,
0, 0, SCREEN_W, SCREEN_H);
}
#endif
/* don't eat CPU... rest some time */
rest(1);
@ -271,14 +305,19 @@ void gui_feedback(void)
void gui_setup_screen(void)
{
#ifdef GUI_DOUBLE_BUFFERED
BITMAP *old_bmp = ji_screen;
ji_set_screen(create_bitmap(SCREEN_W, SCREEN_H));
if (old_bmp && old_bmp != screen)
destroy_bitmap(old_bmp);
#else
ji_set_screen(screen);
#endif
if (double_buffering) {
BITMAP *old_bmp = ji_screen;
ji_set_screen(create_bitmap(SCREEN_W / screen_scaling,
SCREEN_H / screen_scaling));
if (old_bmp && old_bmp != screen)
destroy_bitmap(old_bmp);
}
else {
ji_set_screen(screen);
}
/* set the configuration */
save_gui_config();
}
void reload_default_font(void)
@ -424,7 +463,9 @@ void rebuild_recent_list(void)
{
next_idle_flags |= REBUILD_RECENT_LIST;
}
/**********************************************************************/
/* hook signals */
@ -494,19 +535,19 @@ bool get_widgets(JWidget window, ...)
char *name;
va_list ap;
va_start (ap, window);
while ((name = va_arg (ap, char *))) {
widget = va_arg (ap, JWidget *);
va_start(ap, window);
while ((name = va_arg(ap, char *))) {
widget = va_arg(ap, JWidget *);
if (!widget)
break;
*widget = jwidget_find_name (window, name);
*widget = jwidget_find_name(window, name);
if (!*widget) {
console_printf (_("Widget %s not found.\n"), name);
console_printf(_("Widget %s not found.\n"), name);
return FALSE;
}
}
va_end (ap);
va_end(ap);
return TRUE;
}

View File

@ -21,10 +21,6 @@
#include "jinete/base.h"
#define DEFAULT_GFX_WIDTH 320
#define DEFAULT_GFX_HEIGHT 240
#define DEFAULT_GFX_DEPTH 8
#define HOOK(widget, signal, signal_handler, user_data) \
hook_signal ((widget), (signal), (signal_handler), (int)(user_data))
@ -33,12 +29,9 @@ struct Sprite;
int init_module_gui(void);
void exit_module_gui(void);
void load_gui_config(int *w, int *h, int *bpp, bool *fullscreen);
void save_gui_config(void);
void GUI_Refresh(struct Sprite *sprite);
void run_gui(void);
void gui_run(void);
void gui_feedback(void);
void gui_setup_screen(void);

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,19 +29,19 @@ enum {
ACCEL_MAX
};
int init_module_rootmenu (void);
void exit_module_rootmenu (void);
int init_module_rootmenu(void);
void exit_module_rootmenu(void);
int load_root_menu (void);
int load_root_menu(void);
JWidget get_root_menu (void);
JWidget get_root_menu(void);
JWidget get_sprite_list_menuitem (void);
JWidget get_recent_list_menuitem (void);
JWidget get_layer_popup_menuitem (void);
JWidget get_frame_popup_menuitem (void);
JWidget get_sprite_list_menuitem(void);
JWidget get_recent_list_menuitem(void);
JWidget get_layer_popup_menuitem(void);
JWidget get_frame_popup_menuitem(void);
int check_for_accel (int accel_type, JMessage msg);
void show_filters_popup_menu (void);
int check_for_accel(int accel_type, JMessage msg);
void show_filters_popup_menu(void);
#endif /* MODULES_ROOTMENU_H */

View File

@ -83,7 +83,7 @@ static void update_cursor_color (void)
{
if (cursor_color) {
if (ji_screen)
_cursor_color = get_color_for_allegro(bitmap_color_depth (ji_screen),
_cursor_color = get_color_for_allegro(bitmap_color_depth(ji_screen),
cursor_color);
else
_cursor_color = 0;

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,19 +21,19 @@
#include "raster/image.h"
#include "raster/mask.h"
int main (int argc, char *argv[])
int main(int argc, char *argv[])
{
Mask *mask = NULL;
int redraw;
allegro_init ();
set_gfx_mode (GFX_AUTODETECT, 320, 200, 0, 0);
install_timer ();
install_keyboard ();
install_mouse ();
allegro_init();
set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
install_timer();
install_keyboard();
install_mouse();
set_mouse_sprite_focus (0, 0);
show_mouse (screen);
set_mouse_sprite_focus(0, 0);
show_mouse(screen);
redraw = TRUE;
do {

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -248,7 +248,7 @@ static ImageMethods alleg_methods =
/**********************************************************************/
#endif
Image *image_new (int imgtype, int w, int h)
Image *image_new(int imgtype, int w, int h)
{
Image *image = (Image *)gfxobj_new(GFXOBJ_IMAGE, sizeof(Image));
if (!image)

View File

@ -69,8 +69,8 @@ struct Image
GfxObj gfxobj;
int imgtype;
int w, h;
void *dat; /* pixmap data */
void **line; /* start of each scanline */
unsigned char *dat; /* pixmap data */
unsigned char **line; /* start of each scanline */
struct ImageMethods *method;
/* struct BITMAP *bmp; */
};

View File

@ -8,323 +8,323 @@ routines = [ ]
constants = [ ]
import_routines = [ ]
comment1_regex = re.compile (r"^\/\*")
comment2_regex = re.compile (r"^\/\/")
nullline_regex = re.compile (r"^[ \t]*$")
function_regex = re.compile (r"^ *(?P<type>(const )?[A-Za-z0-9_]+ \*?)?(?P<name>[A-Za-z0-9_]+) \((?P<args>.*)\)(?P<extra>.*)")
void_regex = re.compile (r"^void")
constant_regex = re.compile (r"^\#define (?P<name>[A-Za-z0-9_]+)")
arg_regex = re.compile (r" ?(const )?(?P<type>[A-Za-z_]+ ?\*?\&?)(?P<name>[A-Za-z0-9_]*)")
# userdata_regex = re.compile (r"(?P<type>[A-Za-z_]+) \*$")
# userdata_regex = re.compile (r"(?P<type>[A-Z][a-z_]*)(\ \*)?$")
userdata_regex = re.compile (r"(?P<type>[A-Za-z_]*) ?\*?")
codetag_regex = re.compile (r"CODE")
comment1_regex = re.compile(r"^\/\*")
comment2_regex = re.compile(r"^\/\/")
nullline_regex = re.compile(r"^[ \t]*$")
function_regex = re.compile(r"^ *(?P<type>(const )?[A-Za-z0-9_]+ \*?)?(?P<name>[A-Za-z0-9_]+)\((?P<args>.*)\)(?P<extra>.*)")
void_regex = re.compile(r"^void")
constant_regex = re.compile(r"^\#define (?P<name>[A-Za-z0-9_]+)")
arg_regex = re.compile(r" ?(const )?(?P<type>[A-Za-z_]+ ?\*?\&?)(?P<name>[A-Za-z0-9_]*)")
# userdata_regex = re.compile(r"(?P<type>[A-Za-z_]+) \*$")
# userdata_regex = re.compile(r"(?P<type>[A-Z][a-z_]*)(\ \*)?$")
userdata_regex = re.compile(r"(?P<type>[A-Za-z_]*) ?\*?")
codetag_regex = re.compile(r"CODE")
# ----------------------------------------------------------------------
def convert_to_lua_type (type):
if re.compile (r"^bool").search (type): return "boolean"
if re.compile (r"^int").search (type): return "number"
if re.compile (r"^float").search (type): return "number"
if re.compile (r"^double").search (type): return "number"
if re.compile (r"char\ \*").search (type): return "string"
def convert_to_lua_type(type):
if re.compile(r"^bool").search(type): return "boolean"
if re.compile(r"^int").search(type): return "number"
if re.compile(r"^float").search(type): return "number"
if re.compile(r"^double").search(type): return "number"
if re.compile(r"char\ \*").search(type): return "string"
return "userdata"
# ----------------------------------------------------------------------
def convert_to_c_type (type):
if re.compile (r"^bool").search (type): return "bool "
if re.compile (r"^int").search (type): return "int "
if re.compile (r"^float").search (type): return "float "
if re.compile (r"^double").search (type): return "double "
if re.compile (r"char\ \*").search (type): return "const char *"
def convert_to_c_type(type):
if re.compile(r"^bool").search(type): return "bool "
if re.compile(r"^int").search(type): return "int "
if re.compile(r"^float").search(type): return "float "
if re.compile(r"^double").search(type): return "double "
if re.compile(r"char\ \*").search(type): return "const char *"
return type
# ----------------------------------------------------------------------
def declare_arguments (args, tabs, offset):
def declare_arguments(args, tabs, offset):
if args:
for c in range (len (args)):
arg = arg_regex.match (args[c])
cast = convert_to_c_type (arg.group ("type"))
if not void_regex.search (cast):
lua_type = convert_to_lua_type (arg.group ("type"))
for c in range(len(args)):
arg = arg_regex.match(args[c])
cast = convert_to_c_type(arg.group("type"))
if not void_regex.search(cast):
lua_type = convert_to_lua_type(arg.group("type"))
if lua_type != "userdata":
file_out.write (tabs + convert_to_c_type (arg.group ("type")) +
arg.group ("name") + ";\n")
file_out.write(tabs + convert_to_c_type(arg.group("type")) +
arg.group("name") + ";\n")
else:
userdata = userdata_regex.match (arg.group ("type"))
if userdata and userdata.group ("type"):
# file_out.write (tabs + "UserData *" + arg.group ("name") + ";\n")
# file_out.write (tabs + userdata.group ("type") + " *" + arg.group ("name") + ";\n")
file_out.write (tabs + cast + arg.group ("name") + ";\n")
userdata = userdata_regex.match(arg.group("type"))
if userdata and userdata.group("type"):
# file_out.write(tabs + "UserData *" + arg.group("name") + ";\n")
# file_out.write(tabs + userdata.group("type") + " *" + arg.group("name") + ";\n")
file_out.write(tabs + cast + arg.group("name") + ";\n")
# ----------------------------------------------------------------------
def check_arguments (args, tabs, offset):
def check_arguments(args, tabs, offset):
if args:
for c in range (len (args)):
arg = arg_regex.match (args[c])
cast = convert_to_c_type (arg.group ("type"))
if not void_regex.search (cast):
lua_type = convert_to_lua_type (arg.group ("type"))
for c in range(len(args)):
arg = arg_regex.match(args[c])
cast = convert_to_c_type(arg.group("type"))
if not void_regex.search(cast):
lua_type = convert_to_lua_type(arg.group("type"))
if lua_type != "userdata":
file_out.write (tabs + "GetArg (" +
str (c+offset) + ", " +
arg.group ("name") + ", " +
cast.strip () + ", " +
lua_type + ");\n")
file_out.write(tabs + "GetArg(" +
str(c+offset) + ", " +
arg.group("name") + ", " +
cast.strip() + ", " +
lua_type + ");\n")
else:
userdata = userdata_regex.match (arg.group ("type"))
if userdata and userdata.group ("type"):
# file_out.write (tabs + "GetUD (" +
# str (c+offset) + ", " +
# arg.group ("name") + ");\n")
file_out.write (tabs + "GetUD (" +
str (c+offset) + ", " +
arg.group ("name") + ", " +
userdata.group ("type") + ");\n")
userdata = userdata_regex.match(arg.group("type"))
if userdata and userdata.group("type"):
# file_out.write(tabs + "GetUD(" +
# str(c+offset) + ", " +
# arg.group("name") + ");\n")
file_out.write(tabs + "GetUD(" +
str(c+offset) + ", " +
arg.group("name") + ", " +
userdata.group("type") + ");\n")
# ----------------------------------------------------------------------
def call_arguments (args, offset):
def call_arguments(args, offset):
if args:
for c in range (len (args)):
arg = arg_regex.match (args[c])
cast = convert_to_c_type (arg.group ("type"))
if not void_regex.search (cast):
lua_type = convert_to_lua_type (arg.group ("type"))
file_out.write (arg.group ("name"))
if c < len (args)-1: file_out.write (", ")
for c in range(len(args)):
arg = arg_regex.match(args[c])
cast = convert_to_c_type(arg.group("type"))
if not void_regex.search(cast):
lua_type = convert_to_lua_type(arg.group("type"))
file_out.write(arg.group("name"))
if c < len(args)-1: file_out.write(", ")
# if lua_type != "userdata":
# file_out.write (arg.group ("name"))
# file_out.write(arg.group("name"))
# else:
# userdata = userdata_regex.match (arg.group ("type"))
# if userdata and userdata.group ("type"):
# file_out.write ("GetUD (" +
# userdata.group ("type") + ", " +
# arg.group ("name") + ")")
# userdata = userdata_regex.match(arg.group("type"))
# if userdata and userdata.group("type"):
# file_out.write("GetUD(" +
# userdata.group("type") + ", " +
# arg.group("name") + ")")
# ----------------------------------------------------------------------
def export_function (type, name, args, extra):
args_sep = args.split (',')
def export_function(type, name, args, extra):
args_sep = args.split(',')
print "Export function " + name
if codetag_regex.search (extra):
routines.append (name)
if codetag_regex.search(extra):
routines.append(name)
return
file_out.write ("static int bind_" + name + " (lua_State *L)\n")
file_out.write ("{\n")
file_out.write("static int bind_" + name + "(lua_State *L)\n")
file_out.write("{\n")
# declare return value
if not void_regex.search (type):
file_out.write (" " + convert_to_c_type (type) + "return_value;\n")
if not void_regex.search(type):
file_out.write(" " + convert_to_c_type(type) + "return_value;\n")
# declare arguments
declare_arguments (args_sep, " ", 1)
declare_arguments(args_sep, " ", 1)
# check arguments
check_arguments (args_sep, " ", 1)
check_arguments(args_sep, " ", 1)
# call the routine
file_out.write (" ")
if not void_regex.search (type):
file_out.write ("return_value = ")
file_out.write (name + " (")
call_arguments (args_sep, 1)
file_out.write (");\n")
file_out.write(" ")
if not void_regex.search(type):
file_out.write("return_value = ")
file_out.write(name + "(")
call_arguments(args_sep, 1)
file_out.write(");\n")
# return value
if not void_regex.search (type):
lua_type = convert_to_lua_type (type)
if not void_regex.search(type):
lua_type = convert_to_lua_type(type)
if lua_type == "userdata":
userdata = userdata_regex.match (type)
if userdata and userdata.group ("type"):
file_out.write (" push_userdata (L, Type_" +
userdata.group ("type") + ", return_value);\n")
userdata = userdata_regex.match(type)
if userdata and userdata.group("type"):
file_out.write(" push_userdata(L, Type_" +
userdata.group("type") + ", return_value);\n")
else:
file_out.write (" lua_push" + lua_type + " (L, return_value);\n")
file_out.write (" return 1;\n")
file_out.write(" lua_push" + lua_type + "(L, return_value);\n")
file_out.write(" return 1;\n")
else:
file_out.write (" return 0;\n")
file_out.write(" return 0;\n")
# done
file_out.write ("}\n\n")
file_out.write("}\n\n")
# count this routine
routines.append (name)
routines.append(name)
# ----------------------------------------------------------------------
def export_constant (name):
def export_constant(name):
print "Export constant " + name
constants.append (name)
constants.append(name)
# ----------------------------------------------------------------------
def import_function (type, name, args):
args_sep = args.split (',')
def import_function(type, name, args):
args_sep = args.split(',')
print "Import function " + name
file_out.write (type + name + " (" + args + ")\n")
file_out.write ("{\n")
file_out.write (" lua_State *L = get_lua_state ();\n")
file_out.write(type + name + "(" + args + ")\n")
file_out.write("{\n")
file_out.write(" lua_State *L = get_lua_state();\n")
# declare return value
if not void_regex.search (type):
file_out.write (" " + type + "return_value;\n")
if not void_regex.search(type):
file_out.write(" " + type + "return_value;\n")
# push function
file_out.write (" lua_pushstring (L, \"" + name + "\");\n");
file_out.write (" lua_gettable (L, LUA_GLOBALSINDEX);\n");
file_out.write(" lua_pushstring(L, \"" + name + "\");\n");
file_out.write(" lua_gettable(L, LUA_GLOBALSINDEX);\n");
# how many arguments
if not void_regex.search (args):
nargs = len (args_sep)
if not void_regex.search(args):
nargs = len(args_sep)
else:
nargs = 0
# push arguments
for c in range (nargs):
arg = arg_regex.match (args_sep[c])
cast = convert_to_c_type (arg.group ("type"))
lua_type = convert_to_lua_type (arg.group ("type"))
for c in range(nargs):
arg = arg_regex.match(args_sep[c])
cast = convert_to_c_type(arg.group("type"))
lua_type = convert_to_lua_type(arg.group("type"))
if lua_type != "userdata":
file_out.write (" lua_push" + lua_type + " (L, " +
arg.group ("name") + ");\n")
file_out.write(" lua_push" + lua_type + "(L, " +
arg.group("name") + ");\n")
else:
userdata = userdata_regex.match (arg.group ("type"))
if userdata and userdata.group ("type"):
file_out.write (" push_userdata (L, " +
"Type_" + userdata.group ("type") + ", " +
arg.group ("name") + ");\n")
userdata = userdata_regex.match(arg.group("type"))
if userdata and userdata.group("type"):
file_out.write(" push_userdata(L, " +
"Type_" + userdata.group("type") + ", " +
arg.group("name") + ");\n")
# call the script routine
if not void_regex.search (type):
if not void_regex.search(type):
ret = 1
else:
ret = 0
file_out.write (" do_script_raw (L, " + str (nargs) + ", " + str (ret) + ");\n");
file_out.write(" do_script_raw(L, " + str(nargs) + ", " + str(ret) + ");\n");
# return value
if not void_regex.search (type):
lua_type = convert_to_lua_type (type)
if not void_regex.search(type):
lua_type = convert_to_lua_type(type)
if lua_type != "userdata":
file_out.write (" return_value = lua_to" + lua_type + " (L, -1);\n")
file_out.write(" return_value = lua_to" + lua_type + "(L, -1);\n")
else:
userdata = userdata_regex.match (type)
if userdata and userdata.group ("type"):
file_out.write (" return_value = to_userdata (L, Type_" +
userdata.group ("type") + ", -1);\n");
file_out.write (" lua_pop (L, 1);\n");
file_out.write (" return return_value;\n");
userdata = userdata_regex.match(type)
if userdata and userdata.group("type"):
file_out.write(" return_value = to_userdata(L, Type_" +
userdata.group("type") + ", -1);\n");
file_out.write(" lua_pop(L, 1);\n");
file_out.write(" return return_value;\n");
# done
file_out.write ("}\n\n")
file_out.write("}\n\n")
# ----------------------------------------------------------------------
file_in = open ("export.h", 'r')
file_out = open ("genbinds.c", 'w')
file_in = open("export.h", 'r')
file_out = open("genbinds.c", 'w')
file_out.write ("/* Generated with bindings.gen */\n")
file_out.write ("\n")
file_out.write ("/*======================================================================*/\n")
file_out.write ("/* C -> Lua */\n")
file_out.write ("/*======================================================================*/\n")
file_out.write ("\n")
file_out.write ("#define GetArg(idx, var, cast, type) \\\n")
file_out.write (" if (lua_isnil (L, idx) || lua_is##type (L, idx)) \\\n")
file_out.write (" var = (cast)lua_to##type (L, idx); \\\n")
file_out.write (" else \\\n")
file_out.write (" return 0;\n")
file_out.write ("\n")
file_out.write ("#define GetUD(idx, var, type) \\\n")
file_out.write (" var = to_userdata (L, Type_##type, idx);\n")
file_out.write ("\n")
file_out.write("/* Generated with bindings.gen */\n")
file_out.write("\n")
file_out.write("/*======================================================================*/\n")
file_out.write("/* C -> Lua */\n")
file_out.write("/*======================================================================*/\n")
file_out.write("\n")
file_out.write("#define GetArg(idx, var, cast, type) \\\n")
file_out.write(" if (lua_isnil(L, idx) || lua_is##type(L, idx)) \\\n")
file_out.write(" var = (cast)lua_to##type(L, idx); \\\n")
file_out.write(" else \\\n")
file_out.write(" return 0;\n")
file_out.write("\n")
file_out.write("#define GetUD(idx, var, type) \\\n")
file_out.write(" var = to_userdata(L, Type_##type, idx);\n")
file_out.write("\n")
while 1:
line = file_in.readline ()
line = file_in.readline()
if not line: break
line = line.strip ()
line = line.strip()
# kill comments and white lines
if comment1_regex.search (line): continue
elif comment2_regex.search (line): continue
elif nullline_regex.search (line): continue
# functions: type name (args...)
elif function_regex.search (line):
func = function_regex.match (line)
export_function (func.group ("type"),
func.group ("name"),
func.group ("args"),
func.group ("extra"))
# constants: type name (args...)
elif constant_regex.search (line):
c = constant_regex.match (line)
export_constant (c.group ("name"))
if comment1_regex.search(line): continue
elif comment2_regex.search(line): continue
elif nullline_regex.search(line): continue
# functions: type name(args...)
elif function_regex.search(line):
func = function_regex.match(line)
export_function(func.group("type"),
func.group("name"),
func.group("args"),
func.group("extra"))
# constants: type name(args...)
elif constant_regex.search(line):
c = constant_regex.match(line)
export_constant(c.group("name"))
if len (routines) > 0:
file_out.write ("const luaL_reg bindings_routines[] = {\n")
for c in range (len (routines)):
file_out.write (" { \"" + routines[c] + "\", bind_" + routines[c] + " }")
file_out.write (",\n")
file_out.write (" { NULL, NULL }\n")
file_out.write ("};\n\n")
if len(routines) > 0:
file_out.write("const luaL_reg bindings_routines[] = {\n")
for c in range(len(routines)):
file_out.write(" { \"" + routines[c] + "\", bind_" + routines[c] + " }")
file_out.write(",\n")
file_out.write(" { NULL, NULL }\n")
file_out.write("};\n\n")
if len (constants) > 0:
file_out.write ("struct _bindings_constants bindings_constants[] = {\n")
for c in range (len (constants)):
file_out.write (" { \"" + constants[c] + "\", " + constants[c] + " }")
file_out.write (",\n")
file_out.write (" { NULL, 0 }\n")
file_out.write ("};\n\n")
if len(constants) > 0:
file_out.write("struct _bindings_constants bindings_constants[] = {\n")
for c in range(len(constants)):
file_out.write(" { \"" + constants[c] + "\", " + constants[c] + " }")
file_out.write(",\n")
file_out.write(" { NULL, 0 }\n")
file_out.write("};\n\n")
file_out.write ("void register_bindings (lua_State *L)\n")
file_out.write ("{\n")
file_out.write (" int c;\n")
file_out.write("void register_bindings(lua_State *L)\n")
file_out.write("{\n")
file_out.write(" int c;\n")
if len (routines) > 0:
file_out.write ("\n")
file_out.write (" for (c=0; bindings_routines[c].name; c++)\n")
file_out.write (" lua_register (L,\n")
file_out.write (" bindings_routines[c].name,\n")
file_out.write (" bindings_routines[c].func);\n")
if len(routines) > 0:
file_out.write("\n")
file_out.write(" for (c=0; bindings_routines[c].name; c++)\n")
file_out.write(" lua_register(L,\n")
file_out.write(" bindings_routines[c].name,\n")
file_out.write(" bindings_routines[c].func);\n")
if len (constants) > 0:
file_out.write ("\n")
file_out.write (" for (c=0; bindings_constants[c].name; c++) {\n")
file_out.write (" lua_pushnumber (L, bindings_constants[c].value);\n")
file_out.write (" lua_setglobal (L, bindings_constants[c].name);\n")
file_out.write (" }\n")
if len(constants) > 0:
file_out.write("\n")
file_out.write(" for (c=0; bindings_constants[c].name; c++) {\n")
file_out.write(" lua_pushnumber(L, bindings_constants[c].value);\n")
file_out.write(" lua_setglobal(L, bindings_constants[c].name);\n")
file_out.write(" }\n")
file_out.write ("}\n\n")
file_out.write("}\n\n")
file_in.close ()
file_in = open ("import.h", 'r')
file_in.close()
file_in = open("import.h", 'r')
file_out.write ("/*======================================================================*/\n")
file_out.write ("/* Lua -> C */\n")
file_out.write ("/*======================================================================*/\n")
file_out.write ("\n")
file_out.write("/*======================================================================*/\n")
file_out.write("/* Lua -> C */\n")
file_out.write("/*======================================================================*/\n")
file_out.write("\n")
while 1:
line = file_in.readline ()
line = file_in.readline()
if not line: break
line = line.strip ()
line = line.strip()
# kill comments and white lines
if comment1_regex.search (line): continue
elif comment2_regex.search (line): continue
elif nullline_regex.search (line): continue
# functions: type name (args...)
elif function_regex.search (line):
func = function_regex.match (line)
import_function (func.group ("type"),
func.group ("name"),
func.group ("args"))
if comment1_regex.search(line): continue
elif comment2_regex.search(line): continue
elif nullline_regex.search(line): continue
# functions: type name(args...)
elif function_regex.search(line):
func = function_regex.match(line)
import_function(func.group("type"),
func.group("name"),
func.group("args"))
file_out.write ("\n")
file_out.write("\n")
file_in.close ()
file_out.close ()
file_in.close()
file_out.close()
# header file
file_out = open ("genbinds.h", 'w')
file_out.write ("/* Generated with bindings.gen */\n")
file_out.write ("\n")
file_out.write ("#ifndef SCRIPT_GENBINDS_H\n")
file_out.write ("#define SCRIPT_GENBINDS_H\n")
file_out.write ("\n")
file_out.write ("#include \"script/script.h\"\n")
if len (routines) > 0:
file_out.write ("\n")
file_out.write ("extern const luaL_reg bindings_routines[];\n")
if len (constants) > 0:
file_out.write ("\n");
file_out.write ("struct _bindings_constants {\n")
file_out.write (" const char *name;\n")
file_out.write (" double value;\n")
file_out.write ("};\n")
file_out.write ("\n")
file_out.write ("extern struct _bindings_constants bindings_constants[];\n")
file_out.write ("\n")
file_out.write ("void register_bindings (lua_State *L);\n")
file_out.write ("\n#endif /* SCRIPT_GENBINDS_H */\n")
file_out.close ()
file_out = open("genbinds.h", 'w')
file_out.write("/* Generated with bindings.gen */\n")
file_out.write("\n")
file_out.write("#ifndef SCRIPT_GENBINDS_H\n")
file_out.write("#define SCRIPT_GENBINDS_H\n")
file_out.write("\n")
file_out.write("#include \"script/script.h\"\n")
if len(routines) > 0:
file_out.write("\n")
file_out.write("extern const luaL_reg bindings_routines[];\n")
if len(constants) > 0:
file_out.write("\n");
file_out.write("struct _bindings_constants {\n")
file_out.write(" const char *name;\n")
file_out.write(" double value;\n")
file_out.write("};\n")
file_out.write("\n")
file_out.write("extern struct _bindings_constants bindings_constants[];\n")
file_out.write("\n")
file_out.write("void register_bindings(lua_State *L);\n")
file_out.write("\n#endif /* SCRIPT_GENBINDS_H */\n")
file_out.close()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,6 @@ struct _bindings_constants {
extern struct _bindings_constants bindings_constants[];
void register_bindings (lua_State *L);
void register_bindings(lua_State *L);
#endif /* SCRIPT_GENBINDS_H */

View File

@ -11,46 +11,46 @@
#include "raster/sprite.h"
/* sprite.lua */
void CloseSprite (void);
void CloseSprite(void);
/* layer.lua */
const char *GetUniqueLayerName (void);
const char *GetUniqueLayerName(void);
Layer *NewLayer (const char *name, int x, int y, int w, int h);
Layer *NewLayerSet (const char *name);
void RemoveLayer (void);
Layer *NewLayer(const char *name, int x, int y, int w, int h);
Layer *NewLayerSet(const char *name);
void RemoveLayer(void);
/* remfrm.lua */
void RemoveFrame (Layer *layer, Frame *frame);
void RemoveFrame(Layer *layer, Frame *frame);
/* mask.lua */
void MaskAll (void);
void DeselectMask (void);
void ReselectMask (void);
void InvertMask (void);
void StretchMaskBottom (void);
void MaskAll(void);
void DeselectMask(void);
void ReselectMask(void);
void InvertMask(void);
void StretchMaskBottom(void);
/* effect.lua */
void ConvolutionMatrix (const char *name, bool r, bool g, bool b, bool k, bool a, bool index);
void ConvolutionMatrixRGB (const char *name);
void ConvolutionMatrixRGBA (const char *name);
void ConvolutionMatrixGray (const char *name);
void ConvolutionMatrixGrayA (const char *name);
void ConvolutionMatrixIndex (const char *name);
void ConvolutionMatrixAlpha (const char *name);
void ConvolutionMatrix(const char *name, bool r, bool g, bool b, bool k, bool a, bool index);
void ConvolutionMatrixRGB(const char *name);
void ConvolutionMatrixRGBA(const char *name);
void ConvolutionMatrixGray(const char *name);
void ConvolutionMatrixGrayA(const char *name);
void ConvolutionMatrixIndex(const char *name);
void ConvolutionMatrixAlpha(const char *name);
void _ColorCurve (Curve *curve, bool r, bool g, bool b, bool k, bool a, bool index);
void _ColorCurveRGB (Curve *curve);
void _ColorCurveRGBA (Curve *curve);
void _ColorCurveGray (Curve *curve);
void _ColorCurveGrayA (Curve *curve);
void _ColorCurveIndex (Curve *curve);
void _ColorCurveAlpha (Curve *curve);
void _ColorCurve(Curve *curve, bool r, bool g, bool b, bool k, bool a, bool index);
void _ColorCurveRGB(Curve *curve);
void _ColorCurveRGBA(Curve *curve);
void _ColorCurveGray(Curve *curve);
void _ColorCurveGrayA(Curve *curve);
void _ColorCurveIndex(Curve *curve);
void _ColorCurveAlpha(Curve *curve);
/* void ColorCurve (int array[], bool r, bool g, bool b, bool k, bool a, bool index); */
/* void ColorCurveRGB (int array[]); */
/* void ColorCurveRGBA (int array[]); */
/* void ColorCurveGray (int array[]); */
/* void ColorCurveGrayA (int array[]); */
/* void ColorCurveIndex (int array[]); */
/* void ColorCurveAlpha (int array[]); */
/* void ColorCurve(int array[], bool r, bool g, bool b, bool k, bool a, bool index); */
/* void ColorCurveRGB(int array[]); */
/* void ColorCurveRGBA(int array[]); */
/* void ColorCurveGray(int array[]); */
/* void ColorCurveGrayA(int array[]); */
/* void ColorCurveIndex(int array[]); */
/* void ColorCurveAlpha(int array[]); */

View File

@ -234,8 +234,8 @@ static bool interactive_transform(JWidget widget,
/* #define UPDATE2() \ */
/* jmanager_dispatch_messages (); \ */
/* scare_mouse (); \ */
/* blit (screen, bmp1, vp->x, vp->y, 0, 0, vp->w, vp->h); \ */
/* draw_box (screen, vp->x, vp->y, vp->x+vp->w-1, vp->y+vp->h-1, \ */
/* blit (ji_screen, bmp1, vp->x, vp->y, 0, 0, vp->w, vp->h); \ */
/* draw_box (ji_screen, vp->x, vp->y, vp->x+vp->w-1, vp->y+vp->h-1, \ */
/* x1, y1, x2, y2, preview, mode, angle, cx-vp->x, cy-vp->y); \ */
/* update_status_bar (widget, image, x1, y1, x2, y2, angle); \ */
/* unscare_mouse (); */

View File

@ -20,8 +20,7 @@
#ifndef USE_PRECOMPILED_HEADER
#include <allegro/color.h>
#include <allegro/file.h>
#include <allegro.h>
#include "raster/image.h"
@ -30,7 +29,13 @@
/* loads a COL file (Animator and Animator Pro format) */
RGB *load_col_file(const char *filename)
{
#if (MAKE_VERSION(4, 2, 0) < MAKE_VERSION(ALLEGRO_VERSION, \
ALLEGRO_SUB_VERSION, \
ALLEGRO_WIP_VERSION))
int size = file_size(filename);
#else
int size = file_size_ex(filename);
#endif
int pro = (size == 768)? FALSE: TRUE; /* is Animator Pro format? */
div_t d = div(size-8, 3);
RGB *palette = NULL;

View File

@ -20,7 +20,7 @@
#ifndef USE_PRECOMPILED_HEADER
#include <allegro/file.h>
#include <allegro.h>
#include "raster/image.h"
#include "raster/mask.h"
@ -29,10 +29,16 @@
#endif
/* loads a MSK file (Animator and Animator Pro format) */
Mask *load_msk_file (const char *filename)
Mask *load_msk_file(const char *filename)
{
int size, orig_size = file_size_ex(filename);
int i, c, u, v, byte, magic;
#if (MAKE_VERSION(4, 2, 0) < MAKE_VERSION(ALLEGRO_VERSION, \
ALLEGRO_SUB_VERSION, \
ALLEGRO_WIP_VERSION))
int orig_size = file_size(filename);
#else
int orig_size = file_size_ex(filename);
#endif
int i, c, u, v, byte, magic, size;
Mask *mask = NULL;
PACKFILE *f;
@ -92,10 +98,10 @@ Mask *load_msk_file (const char *filename)
}
/* saves an Animator Pro MSK file (really a PIC file) */
int save_msk_file (Mask *mask, const char *filename)
int save_msk_file(Mask *mask, const char *filename)
{
if (mask->bitmap)
return save_pic_file (filename, mask->x, mask->y, NULL, mask->bitmap);
return save_pic_file(filename, mask->x, mask->y, NULL, mask->bitmap);
else
return -1;
}

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -43,12 +43,12 @@ static unsigned char *omap;
static unsigned char *cmap;
static BITMAP *old_bmp;
bool is_rec_screen (void)
bool is_rec_screen(void)
{
return rec_file ? TRUE: FALSE;
}
void rec_screen_on (void)
void rec_screen_on(void)
{
char buf[512];
int c;
@ -103,7 +103,7 @@ void rec_screen_on (void)
rec_clock = ji_clock;
}
void rec_screen_off (void)
void rec_screen_off(void)
{
if (rec_file) {
/* write the header and close the file */

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,12 +21,12 @@
#include "jinete/base.h"
bool is_rec_screen (void);
bool is_rec_screen(void);
void rec_screen_on (void);
void rec_screen_off (void);
void rec_screen_on(void);
void rec_screen_off(void);
void rec_screen_poll (void);
void rec_screen_poll(void);
#endif /* UTIL_RECSCR_H */

View File

@ -124,22 +124,19 @@ int set_gfx(const char *_card, int w, int h, int depth)
else {
gui_setup_screen();
/* set the configuration */
save_gui_config();
/* set to a black palette */
set_current_palette(black_palette, TRUE);
/* restore palette all screen stuff */
app_refresh_screen();
}
/* setup mouse */
show_mouse(ji_screen);
/* show_mouse(ji_screen); */
_setup_mouse_speed();
/* redraw top window */
if(app_get_top_window()) {
if (app_get_top_window()) {
jwindow_remap(app_get_top_window());
jmanager_refresh_screen();
}

View File

@ -180,7 +180,7 @@ int editor_keys_toget_pixels(JWidget widget, int scancode)
int x, y;
/* pixel position to get */
screen_to_editor (widget, ji_mouse_x (0), ji_mouse_y (0), &x, &y);
screen_to_editor(widget, ji_mouse_x(0), ji_mouse_y(0), &x, &y);
/* get the color from the image */
color = color_from_image(editor->sprite->imgtype,

View File

@ -1,5 +1,5 @@
/* ase -- allegro-sprite-editor: the ultimate sprites factory
* Copyright (C) 2001-2005 David A. Capello
* Copyright (C) 2001-2005, 2007 David A. Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,10 +35,10 @@
#endif
static int group_change_signal (JWidget widget, int user_data);
static void conf_command (JWidget widget);
static int group_change_signal(JWidget widget, int user_data);
static void conf_command(JWidget widget);
JWidget tool_bar_new (int align)
JWidget tool_bar_new(int align)
{
#define ICONS_LIST \
GFX_TOOL_MARKER, \
@ -54,41 +54,42 @@ JWidget tool_bar_new (int align)
JWidget box, fillbox, confbutton, group;
int c, len;
for (c=0; ase_tools_list[c]; c++);
for (c=0; ase_tools_list[c]; c++)
;
len = c;
for (c=0; ase_tools_list[c]; c++)
if (current_tool == ase_tools_list[c])
break;
box = jbox_new (align);
fillbox = jbox_new (align);
confbutton = jbutton_new (NULL);
box = jbox_new(align);
fillbox = jbox_new(align);
confbutton = jbutton_new(NULL);
add_gfxicon_to_button (confbutton, GFX_TOOL_CONFIGURATION,
JI_CENTER | JI_MIDDLE);
add_gfxicon_to_button(confbutton, GFX_TOOL_CONFIGURATION,
JI_CENTER | JI_MIDDLE);
if (align == JI_HORIZONTAL)
group = group_button_new (len, 1, c, ICONS_LIST);
group = group_button_new(len, 1, c, ICONS_LIST);
else
group = group_button_new (1, len, c, ICONS_LIST);
group = group_button_new(1, len, c, ICONS_LIST);
jwidget_expansive (box, TRUE);
jwidget_expansive (fillbox, TRUE);
jwidget_expansive(box, TRUE);
jwidget_expansive(fillbox, TRUE);
jwidget_add_child (box, group);
jwidget_add_child (box, fillbox);
jwidget_add_child (box, confbutton);
jwidget_add_child(box, group);
jwidget_add_child(box, fillbox);
jwidget_add_child(box, confbutton);
HOOK (group, SIGNAL_GROUP_BUTTON_CHANGE, group_change_signal, 0);
jbutton_add_command (confbutton, conf_command);
HOOK(group, SIGNAL_GROUP_BUTTON_CHANGE, group_change_signal, 0);
jbutton_add_command(confbutton, conf_command);
box->user_data[0] = group;
return box;
}
void tool_bar_update (JWidget widget)
void tool_bar_update(JWidget widget)
{
JWidget group = widget->user_data[0];
int c;
@ -97,20 +98,20 @@ void tool_bar_update (JWidget widget)
if (current_tool == ase_tools_list[c])
break;
group_button_select (group, c);
group_button_select(group, c);
}
static int group_change_signal (JWidget widget, int user_data)
static int group_change_signal(JWidget widget, int user_data)
{
int c = group_button_get_selected (widget);
int c = group_button_get_selected(widget);
if (current_tool != ase_tools_list[c])
select_tool (ase_tools_list[c]->name);
select_tool(ase_tools_list[c]->name);
return FALSE;
}
static void conf_command (JWidget widget)
static void conf_command(JWidget widget)
{
GUI_ToolsConfiguration ();
dialogs_tools_configuration();
}

View File

@ -6,9 +6,7 @@ gfli/
Routines to load/save FLI/FLC files.
This is a shorten version of gfli 1.3, you can get the entire
package from:
http://www.gimp.org/ (search in the plug-ins)
Also, I fixed some bugs with color chunks.
libart_lgpl/
@ -16,18 +14,28 @@ libart_lgpl/
Routines to handle paths.
This is a shorten version of libart 2.3.3, you can get the entire
package from:
http://www.levien.com/libart/
libpng/
Routines to load/save PNG files.
This is a shorten version of libpng 1.2.20, you can get the entire
package from:
http://www.libpng.org/
lua/
Routines to do scripting.
This is a shorten version of lua 5.0, you can get the entire package
from:
http://www.lua.org/
Also, this version has a patch to make the operator != works like ~=
zlib/
Used by libpng
This is a shorten version of zlib 1.2.3.
http://www.zlib.net/
----------------------------------------------------------------------
David A. Capello

109
third_party/libpng/LICENSE vendored Normal file
View File

@ -0,0 +1,109 @@
This copy of the libpng notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.2.6, August 15, 2004, through 1.2.20, September 8, 2007, are
Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
Simon-Pierre Cadieux
Eric S. Raymond
Gilles Vollant
and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
John Bowler
Kevin Bracey
Sam Bushell
Magnus Holmgren
Greg Roelofs
Tom Tanner
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
Andreas Dilger
Dave Martindale
Guy Eric Schalnat
Paul Schmidt
Tim Wegner
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
printf("%s",png_get_copyright(NULL));
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
September 8, 2007

263
third_party/libpng/README vendored Normal file
View File

@ -0,0 +1,263 @@
README for libpng version 1.2.20 - September 8, 2007 (shared library 12.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
Libpng comes in several distribution formats. Get libpng-*.tar.gz
or libpng-*.tar.bz2 if you want UNIX-style line endings in the text
files, or lpng*.zip if you want DOS-style line endings.
Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in
extensive use and testing since mid-1995. By late 1997 it had
finally gotten to the stage where there hadn't been significant
changes to the API in some time, and people have a bad feeling about
libraries with versions < 1.0. Version 1.0.0 was released in
March 1998.
****
Note that some of the changes to the png_info structure render this
version of the library binary incompatible with libpng-0.89 or
earlier versions if you are using a shared library. The type of the
"filler" parameter for png_set_filler() has changed from png_byte to
png_uint_32, which will affect shared-library applications that use
this function.
To avoid problems with changes to the internals of png_info_struct,
new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when
accessing/storing the info_struct data, rather than manipulating it
directly, to avoid such problems in the future.
It is important to note that the APIs do not make current programs
that access the info struct directly incompatible with the new
library. However, it is strongly suggested that new programs use
the new APIs (as shown in example.c and pngtest.c), and older programs
be converted to the new format, to facilitate upgrades in the future.
****
Additions since 0.90 include the ability to compile libpng as a
Windows DLL, and new APIs for accessing data in the info struct.
Experimental functions include the ability to set weighting and cost
factors for row filter selection, direct reads of integers from buffers
on big-endian processors that support misaligned data access, faster
methods of doing alpha composition, and more accurate 16->8 bit color
conversion.
The additions since 0.89 include the ability to read from a PNG stream
which has had some (or all) of the signature bytes read by the calling
application. This also allows the reading of embedded PNG streams that
do not have the PNG file signature. As well, it is now possible to set
the library action on the detection of chunk CRC errors. It is possible
to set different actions based on whether the CRC error occurred in a
critical or an ancillary chunk.
The changes made to the library, and bugs fixed are based on discussions
on the PNG-implement mailing list
and not on material submitted privately to Guy, Andreas, or Glenn. They will
forward any good suggestions to the list.
For a detailed description on using libpng, read libpng.txt. For
examples of libpng in a program, see example.c and pngtest.c. For usage
information and restrictions (what little they are) on libpng, see
png.h. For a description on using zlib (the compression library used by
libpng) and zlib's restrictions, see zlib.h
I have included a general makefile, as well as several machine and
compiler specific ones, but you may have to modify one for your own needs.
You should use zlib 1.0.4 or later to run this, but it MAY work with
versions as old as zlib 0.95. Even so, there are bugs in older zlib
versions which can cause the output of invalid compression streams for
some images. You will definitely need zlib 1.0.4 or later if you are
taking advantage of the MS-DOS "far" structure allocation for the small
and medium memory models. You should also note that zlib is a
compression library that is useful for more things than just PNG files.
You can use zlib as a drop-in replacement for fread() and fwrite() if
you are so inclined.
zlib should be available at the same place that libpng is, or at.
ftp://ftp.info-zip.org/pub/infozip/zlib
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
at GO GRAPHSUP. If you can't find it in any of those places,
e-mail me, and I'll help you find it.
If you have any code changes, requests, problems, etc., please e-mail
them to me. Also, I'd appreciate any make files or project files,
and any modifications you needed to make to get libpng to compile,
along with a #define variable to tell what compiler/system you are on.
If you needed to add transformations to libpng, or wish libpng would
provide the image in a different way, drop me a note (and code, if
possible), so I can consider supporting the transformation.
Finally, if you get any warning messages when compiling libpng
(note: not zlib), and they are easy to fix, I'd appreciate the
fix. Please mention "libpng" somewhere in the subject line. Thanks.
This release was created and will be supported by myself (of course
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net
You can't reach Guy, the original libpng author, at the addresses
given in previous versions of this document. He and Andreas will read mail
addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
the (png-list at ccrc.wustl.edu, subscription required, write to
majordomo at ccrc.wustl.edu with "subscribe png-list" in your message).
On the other hand,
please do not send libpng questions to that address, send them to me
or to the png-implement list. I'll
get them in the end anyway. If you have a question about something
in the PNG specification that is related to using libpng, send it
to me. Send me any questions that start with "I was using libpng,
and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for nine years now, and it is official and
finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately,
it may be used later.
Files in this distribution:
ANNOUNCE => Announcement of this version, with recent changes
CHANGES => Description of changes between libpng versions
KNOWNBUG => List of known bugs and deficiencies
LICENSE => License to use and redistribute libpng
README => This file
TODO => Things not implemented in the current library
Y2KINFO => Statement of Y2K compliance
example.c => Example code for using libpng functions
libpng.3 => manual page for libpng (includes libpng.txt)
libpng.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private functions
png.5 => manual page for the PNG format
png.c => Basic interface functions common to library
png.h => Library function and interface declarations
pngconf.h => System specific library configuration
pngasmrd.h => Header file for assembler-coded functions
pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions
pngbar.png => PNG logo, 88x31
pngnow.png => PNG logo, 98x31
pngpread.c => Progressive reading functions
pngread.c => Read data/helper high-level functions
pngrio.c => Lowest-level data read I/O functions
pngrtran.c => Read data transformation functions
pngrutil.c => Read data utility functions
pngset.c => Functions for storing data into the info_struct
pngtest.c => Library test program
pngtest.png => Library test sample image
pngtrans.c => Common data transformation functions
pngwio.c => Lowest-level write I/O functions
pngwrite.c => High-level write functions
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
contrib => Contributions
gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999
msvctest => Builds and runs pngtest using a MSVC workspace
pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
visupng => Contains a MSVC workspace for VisualPng
projects => Contains project files and workspaces for building DLL
beos => Contains a Beos workspace for building libpng
c5builder => Contains a Borland workspace for building libpng
and zlib
visualc6 => Contains a Microsoft Visual C++ (MSVC) workspace
for building libpng and zlib
netware.txt => Contains instructions for downloading a set of
project files for building libpng and zlib on
Netware.
wince.txt => Contains instructions for downloading a Microsoft
Visual C++ (Windows CD Toolkit) workspace for
building libpng and zlib on WindowsCE
scripts => Directory containing scripts for building libpng:
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng12.so.0.1.2.20)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.20)
makefile.gcmmx => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.20,
uses assembler code tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX makefile
makefile.cygwin => Cygwin/gcc makefile
makefile.darwin => Darwin makefile
makefile.dec => DEC Alpha UNIX makefile
makefile.freebsd => FreeBSD makefile
makefile.hpgcc => HPUX makefile using gcc
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
makefile.intel => Intel C/C++ version 4.0 and later
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so.
makefile.ne12bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng12.so
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics
(gcc, creates libpng12.so.0.1.2.20)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng12.so.0.1.2.20)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng12.so.0.1.2.20)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
makefile.amiga => Amiga makefile
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC
compiler (Requires SCOPTIONS, copied from
scripts/SCOPTIONS.ppc)
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.bor => Borland makefile (uses bcc)
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
makefile.tc3 => Turbo C 3.0 makefile
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and
later (uses assembler code tuned for Intel MMX
platform)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
later (does not use assembler code)
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
SCOPTIONS.ppc => Used with smakefile.ppc
Good luck, and happy coding.
-Glenn Randers-Pehrson (current maintainer)
Internet: glennrp at users.sourceforge.net
-Andreas Eric Dilger (former maintainer, 1996-1997)
Internet: adilger at enel.ucalgary.ca
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc)
Internet: gschal at infinet.com

24
third_party/libpng/TODO vendored Normal file
View File

@ -0,0 +1,24 @@
TODO - list of things to do for libpng:
Final bug fixes.
Improve API by hiding the png_struct and png_info structs.
Finish work on the no-floating-point version (including gamma compensation)
Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Man pages for function calls.
Better documentation.
Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?).
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety?
Build gamma tables using fixed point (and do away with floating point entirely).
Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.

55
third_party/libpng/Y2KINFO vendored Normal file
View File

@ -0,0 +1,55 @@
Y2K compliance in libpng:
=========================
September 8, 2007
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.2.20 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer
that will hold years up to 65535. The other two hold the date in text
format, and will hold years up to 9999.
The integer is
"png_uint_16 year" in png_time_struct.
The strings are
"png_charp time_buffer" in png_struct and
"near_time_buffer", which is a local character string in png.c.
There are seven time-related functions:
png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
png_convert_from_time_t() in pngwrite.c
png_get_tIME() in pngget.c
png_handle_tIME() in pngrutil.c, called in pngread.c
png_set_tIME() in pngset.c
png_write_tIME() in pngwutil.c, called in pngwrite.c
All appear to handle dates properly in a Y2K environment. The
png_convert_from_time_t() function calls gmtime() to convert from system
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
function, or that they are incorrectly passing only a 2-digit year
instead of "year - 1900" into the png_convert_from_struct_tm() function,
but this is not under our control. The libpng documentation has always
stated that it works with 4-digit years, and the APIs have been
documented as such.
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
integer to hold the year, and can hold years as large as 65535.
zlib, upon which libpng depends, is also Y2K compliant. It contains
no date-related code.
Glenn Randers-Pehrson
libpng maintainer
PNG Development Group

814
third_party/libpng/example.c vendored Normal file
View File

@ -0,0 +1,814 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.2.1 December 7, 2001.
* This file has been placed in the public domain by the authors.
* Maintained 1998-2007 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
/* This is an example of how to use libpng to read and write PNG files.
* The file libpng.txt is much more verbose then this. If you have not
* read it, do so first. This was designed to be a starting point of an
* implementation. This is not officially part of libpng, is hereby placed
* in the public domain, and therefore does not require a copyright notice.
*
* This file does not currently compile, because it is missing certain
* parts, like allocating memory to hold an image. You will have to
* supply these parts to get it to compile. For an example of a minimal
* working PNG reader/writer, see pngtest.c, included in this distribution;
* see also the programs in the contrib directory.
*/
#include "png.h"
/* The png_jmpbuf() macro, used in error handling, became available in
* libpng version 1.0.6. If you want to be able to run your code with older
* versions of libpng, you must define the macro yourself (but only if it
* is not already defined by libpng!).
*/
#ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
*
* The function check_if_png() shown here, but not used, returns nonzero (true)
* if the file can be opened and is a PNG, 0 (false) otherwise.
*
* If this call is successful, and you are going to keep the file open,
* you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
* you have created the png_ptr, so that libpng knows your application
* has read that many bytes from the start of the file. Make sure you
* don't call png_set_sig_bytes() with more than 8 bytes read or give it
* an incorrect number of bytes read, or you will either have read too
* many bytes (your fault), or you are telling libpng to read the wrong
* number of magic bytes (also your fault).
*
* Many applications already read the first 2 or 4 bytes from the start
* of the image to determine the file type, so it would be easiest just
* to pass the bytes to png_sig_cmp() or even skip that if you know
* you have a PNG file, and call png_set_sig_bytes().
*/
#define PNG_BYTES_TO_CHECK 4
int check_if_png(char *file_name, FILE **fp)
{
char buf[PNG_BYTES_TO_CHECK];
/* Open the prospective PNG file. */
if ((*fp = fopen(file_name, "rb")) == NULL)
return 0;
/* Read in some of the signature bytes */
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
return 0;
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
Return nonzero (true) if they match */
return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
}
/* Read a PNG file. You may want to return an error code if the read
* fails (depending upon the failure). There are two "prototypes" given
* here - one where we are given the filename, and we need to open the
* file, and the other where we are given an open file (possibly with
* some or all of the magic bytes read - see comments above).
*/
#ifdef open_file /* prototype 1 */
void read_png(char *file_name) /* We need to open the file */
{
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL)
return (ERROR);
#else no_open_file /* prototype 2 */
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
{
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
#endif no_open_file /* only use one prototype! */
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also supply the
* the compiler header file version, so that we know if the application
* was compiled with a compatible version of the library. REQUIRED
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
fclose(fp);
return (ERROR);
}
/* Allocate/initialize the memory for image information. REQUIRED. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(fp);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return (ERROR);
}
/* Set error handling if you are using the setjmp/longjmp method (this is
* the normal method of doing things with libpng). REQUIRED unless you
* set up your own error handlers in the png_create_read_struct() earlier.
*/
if (setjmp(png_jmpbuf(png_ptr)))
{
/* Free all of the memory associated with the png_ptr and info_ptr */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fclose(fp);
/* If we get here, we had a problem reading the file */
return (ERROR);
}
/* One of the following I/O initialization methods is REQUIRED */
#ifdef streams /* PNG file I/O method 1 */
/* Set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* PNG file I/O method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call:
*/
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* Use only one I/O method! */
/* If we have already read some of the signature */
png_set_sig_bytes(png_ptr, sig_read);
#ifdef hilevel
/*
* If you have enough memory to read in the entire image at once,
* and you need to specify only transforms that can be controlled
* with one of the PNG_TRANSFORM_* bits (this presently excludes
* dithering, filling, setting background, and doing gamma
* adjustment), then you can read the entire image (including
* pixels) into the info structure with this call:
*/
png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else
/* OK, you're doing it the hard way, with the lower-level functions */
/* The call to png_read_info() gives us all of the information from the
* PNG file before the first IDAT (image data chunk). REQUIRED
*/
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, int_p_NULL, int_p_NULL);
/* Set up the data transformations you want. Note that these are all
* optional. Only call them if you want/need them. Many of the
* transformations only work on specific types of images, and many
* are mutually exclusive.
*/
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
png_set_strip_alpha(png_ptr);
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
png_set_packing(png_ptr);
/* Change the order of packed pixels to least significant bit first
* (not useful if you are using png_set_packing). */
png_set_packswap(png_ptr);
/* Expand paletted colors into true RGB triplets */
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
png_set_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets.
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png_ptr);
/* Set the background color to draw transparent and alpha images over.
* It is possible to set the red, green, and blue components directly
* for paletted images instead of supplying a palette index. Note that
* even if the PNG file supplies a background, you are not required to
* use it - you should use the (solid) application background if it has one.
*/
png_color_16 my_background, *image_background;
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
/* Some suggestions as to how to get a screen gamma value */
/* Note that screen gamma is the display_exponent, which includes
* the CRT_exponent and any correction for viewing conditions */
if (/* We have a user-defined screen gamma value */)
{
screen_gamma = user-defined screen_gamma;
}
/* This is one way that applications share the same screen gamma value */
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
{
screen_gamma = atof(gamma_str);
}
/* If we don't have another value */
else
{
screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly
lit room */
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
}
/* Tell libpng to handle the gamma conversion for you. The final call
* is a good guess for PC generated images, but it should be configurable
* by the user at run time by the user. It is strongly suggested that
* your application support gamma correction.
*/
int intent;
if (png_get_sRGB(png_ptr, info_ptr, &intent))
png_set_gamma(png_ptr, screen_gamma, 0.45455);
else
{
double image_gamma;
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
png_set_gamma(png_ptr, screen_gamma, image_gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.45455);
}
/* Dither RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
*/
if (color_type & PNG_COLOR_MASK_COLOR)
{
int num_palette;
png_colorp palette;
/* This reduces the image to the application supplied palette */
if (/* we have our own palette */)
{
/* An array of colors to which the image should be dithered */
png_color std_color_cube[MAX_SCREEN_COLORS];
png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
MAX_SCREEN_COLORS, png_uint_16p_NULL, 0);
}
/* This reduces the image to the palette supplied in the file */
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
{
png_uint_16p histogram = NULL;
png_get_hIST(png_ptr, info_ptr, &histogram);
png_set_dither(png_ptr, palette, num_palette,
max_screen_colors, histogram, 0);
}
}
/* invert monochrome files to have 0 as white and 1 as black */
png_set_invert_mono(png_ptr);
/* If you want to shift the pixel values from the range [0,255] or
* [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
{
png_color_8p sig_bit;
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
png_set_shift(png_ptr, sig_bit);
}
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
if (color_type & PNG_COLOR_MASK_COLOR)
png_set_bgr(png_ptr);
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
png_set_swap_alpha(png_ptr);
/* swap bytes of 16 bit files to least significant byte first */
png_set_swap(png_ptr);
/* Add filler (or alpha) byte (before/after each RGB triplet) */
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
/* Turn on interlace handling. REQUIRED if you are not using
* png_read_image(). To see how to handle interlacing passes,
* see the png_read_row() method below:
*/
number_passes = png_set_interlace_handling(png_ptr);
/* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above).
*/
png_read_update_info(png_ptr, info_ptr);
/* Allocate the memory to hold the image using the fields of info_ptr. */
/* The easiest way to read the image: */
png_bytep row_pointers[height];
for (row = 0; row < height; row++)
{
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr));
}
/* Now it's time to read the image. One of these methods is REQUIRED */
#ifdef entire /* Read the entire image in one go */
png_read_image(png_ptr, row_pointers);
#else no_entire /* Read the image one or more scanlines at a time */
/* The other way to read images - deal with interlacing: */
for (pass = 0; pass < number_passes; pass++)
{
#ifdef single /* Read the image a single row at a time */
for (y = 0; y < height; y++)
{
png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1);
}
#else no_single /* Read the image several rows at a time */
for (y = 0; y < height; y += number_of_rows)
{
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL,
number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y],
number_of_rows);
#endif no_sparkle /* use only one of these two methods */
}
/* if you want to display the image after every pass, do
so here */
#endif no_single /* use only one of these two methods */
}
#endif no_entire /* use only one of these two methods */
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
#endif hilevel
/* At this point you have read the entire image */
/* clean up after the read, and free any memory allocated - REQUIRED */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
/* close the file */
fclose(fp);
/* that's it */
return (OK);
}
/* progressively read a file */
int
initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
{
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that
* the library version is compatible in case we are using dynamically
* linked libraries.
*/
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (*png_ptr == NULL)
{
*info_ptr = NULL;
return (ERROR);
}
*info_ptr = png_create_info_struct(png_ptr);
if (*info_ptr == NULL)
{
png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL);
return (ERROR);
}
if (setjmp(png_jmpbuf((*png_ptr))))
{
png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL);
return (ERROR);
}
/* This one's new. You will need to provide all three
* function callbacks, even if you aren't using them all.
* If you aren't using all functions, you can specify NULL
* parameters. Even when all three functions are NULL,
* you need to call png_set_progressive_read_fn().
* These functions shouldn't be dependent on global or
* static variables if you are decoding several images
* simultaneously. You should store stream specific data
* in a separate struct, given as the second parameter,
* and retrieve the pointer from inside the callbacks using
* the function png_get_progressive_ptr(png_ptr).
*/
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback);
return (OK);
}
int
process_data(png_structp *png_ptr, png_infop *info_ptr,
png_bytep buffer, png_uint_32 length)
{
if (setjmp(png_jmpbuf((*png_ptr))))
{
/* Free the png_ptr and info_ptr memory on error */
png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL);
return (ERROR);
}
/* This one's new also. Simply give it chunks of data as
* they arrive from the data stream (in order, of course).
* On Segmented machines, don't give it any more than 64K.
* The library seems to run fine with sizes of 4K, although
* you can give it much less if necessary (I assume you can
* give it chunks of 1 byte, but I haven't tried with less
* than 256 bytes yet). When this function returns, you may
* want to display any rows that were generated in the row
* callback, if you aren't already displaying them there.
*/
png_process_data(*png_ptr, *info_ptr, buffer, length);
return (OK);
}
info_callback(png_structp png_ptr, png_infop info)
{
/* do any setup here, including setting any of the transformations
* mentioned in the Reading PNG files section. For now, you _must_
* call either png_start_read_image() or png_read_update_info()
* after all the transformations are set (even if you don't set
* any). You may start getting rows before png_process_data()
* returns, so this is your last chance to prepare for that.
*/
}
row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass)
{
/*
* This function is called for every row in the image. If the
* image is interlaced, and you turned on the interlace handler,
* this function will be called for every row in every pass.
*
* In this function you will receive a pointer to new row data from
* libpng called new_row that is to replace a corresponding row (of
* the same data format) in a buffer allocated by your application.
*
* The new row data pointer new_row may be NULL, indicating there is
* no new data to be replaced (in cases of interlace loading).
*
* If new_row is not NULL then you need to call
* png_progressive_combine_row() to replace the corresponding row as
* shown below:
*/
/* Check if row_num is in bounds. */
if((row_num >= 0) && (row_num < height))
{
/* Get pointer to corresponding row in our
* PNG read buffer.
*/
png_bytep old_row = ((png_bytep *)our_data)[row_num];
/* If both rows are allocated then copy the new row
* data to the corresponding row data.
*/
if((old_row != NULL) && (new_row != NULL))
png_progressive_combine_row(png_ptr, old_row, new_row);
}
/*
* The rows and passes are called in order, so you don't really
* need the row_num and pass, but I'm supplying them because it
* may make your life easier.
*
* For the non-NULL rows of interlaced images, you must call
* png_progressive_combine_row() passing in the new row and the
* old row, as demonstrated above. You can call this function for
* NULL rows (it will just return) and for non-interlaced images
* (it just does the png_memcpy for you) if it will make the code
* easier. Thus, you can just do this for all cases:
*/
png_progressive_combine_row(png_ptr, old_row, new_row);
/* where old_row is what was displayed for previous rows. Note
* that the first pass (pass == 0 really) will completely cover
* the old row, so the rows do not have to be initialized. After
* the first pass (and only for interlaced images), you will have
* to pass the current row as new_row, and the function will combine
* the old row and the new row.
*/
}
end_callback(png_structp png_ptr, png_infop info)
{
/* this function is called when the whole image has been read,
* including any chunks after the image (up to and including
* the IEND). You will usually have the same info chunk as you
* had in the header, although some data may have been added
* to the comments and time fields.
*
* Most people won't do much here, perhaps setting a flag that
* marks the image as finished.
*/
}
/* write a png file */
void write_png(char *file_name /* , ... other image information ... */)
{
FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
png_colorp palette;
/* open the file */
fp = fopen(file_name, "wb");
if (fp == NULL)
return (ERROR);
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that
* the library version is compatible with the one used at compile time,
* in case we are using dynamically linked libraries. REQUIRED.
*/
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
fclose(fp);
return (ERROR);
}
/* Allocate/initialize the image information data. REQUIRED */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, png_infopp_NULL);
return (ERROR);
}
/* Set error handling. REQUIRED if you aren't supplying your own
* error handling functions in the png_create_write_struct() call.
*/
if (setjmp(png_jmpbuf(png_ptr)))
{
/* If we get here, we had a problem reading the file */
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
return (ERROR);
}
/* One of the following I/O initialization functions is REQUIRED */
#ifdef streams /* I/O initialization method 1 */
/* set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* I/O initialization method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call */
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* only use one initialization method */
#ifdef hilevel
/* This is the easy way. Use it if you already have all the
* image info living info in the structure. You could "|" many
* PNG_TRANSFORM flags into the png_transforms integer here.
*/
png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else
/* This is the hard way */
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
*/
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* png_sizeof (png_color));
/* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to
the palette that you malloced. Wait until you are about to destroy
the png structure. */
/* optional significant bit chunk */
/* if we are dealing with a grayscale image then */
sig_bit.gray = true_bit_depth;
/* otherwise, if we are dealing with a color image then */
sig_bit.red = true_red_bit_depth;
sig_bit.green = true_green_bit_depth;
sig_bit.blue = true_blue_bit_depth;
/* if the image has an alpha channel then */
sig_bit.alpha = true_alpha_bit_depth;
png_set_sBIT(png_ptr, info_ptr, sig_bit);
/* Optional gamma chunk is strongly suggested if you have any guess
* as to the correct gamma of the image.
*/
png_set_gAMA(png_ptr, info_ptr, gamma);
/* Optionally write comments into the image */
text_ptr[0].key = "Title";
text_ptr[0].text = "Mona Lisa";
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[1].key = "Author";
text_ptr[1].text = "Leonardo DaVinci";
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[2].key = "Description";
text_ptr[2].text = "<long text>";
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
#ifdef PNG_iTXt_SUPPORTED
text_ptr[0].lang = NULL;
text_ptr[1].lang = NULL;
text_ptr[2].lang = NULL;
#endif
png_set_text(png_ptr, info_ptr, text_ptr, 3);
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
/* note that if sRGB is present the gAMA and cHRM chunks must be ignored
* on read and must be written in accordance with the sRGB profile */
/* Write the file header information. REQUIRED */
png_write_info(png_ptr, info_ptr);
/* If you want, you can write the info in two steps, in case you need to
* write your private chunk ahead of PLTE:
*
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
* write_my_chunk();
* png_write_info(png_ptr, info_ptr);
*
* However, given the level of known- and unknown-chunk support in 1.1.0
* and up, this should no longer be necessary.
*/
/* Once we write out the header, the compression type on the text
* chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
* PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again
* at the end.
*/
/* set up the transformations you want. Note that these are
* all optional. Only call them if you want them.
*/
/* invert monochrome pixels */
png_set_invert_mono(png_ptr);
/* Shift the pixels up to a legal bit depth and fill in
* as appropriate to correctly scale the image.
*/
png_set_shift(png_ptr, &sig_bit);
/* pack pixels into bytes */
png_set_packing(png_ptr);
/* swap location of alpha bytes from ARGB to RGBA */
png_set_swap_alpha(png_ptr);
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
* RGB (4 channels -> 3 channels). The second parameter is not used.
*/
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
/* flip BGR pixels to RGB */
png_set_bgr(png_ptr);
/* swap bytes of 16-bit files to most significant byte first */
png_set_swap(png_ptr);
/* swap bits of 1, 2, 4 bit packed pixel formats */
png_set_packswap(png_ptr);
/* turn on interlace handling if you are not using png_write_image() */
if (interlacing)
number_passes = png_set_interlace_handling(png_ptr);
else
number_passes = 1;
/* The easiest way to write the image (you may have a different memory
* layout, however, so choose what fits your needs best). You need to
* use the first method if you aren't handling interlacing yourself.
*/
png_uint_32 k, height, width;
png_byte image[height][width*bytes_per_pixel];
png_bytep row_pointers[height];
if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
png_error (png_ptr, "Image is too tall to process in memory");
for (k = 0; k < height; k++)
row_pointers[k] = image + k*width*bytes_per_pixel;
/* One of the following output methods is REQUIRED */
#ifdef entire /* write out the entire image data in one call */
png_write_image(png_ptr, row_pointers);
/* the other way to write the image - deal with interlacing */
#else no_entire /* write out the image data by one or more scanlines */
/* The number of passes is either 1 for non-interlaced images,
* or 7 for interlaced images.
*/
for (pass = 0; pass < number_passes; pass++)
{
/* Write a few rows at a time. */
png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
/* If you are only writing one row at a time, this works */
for (y = 0; y < height; y++)
{
png_write_rows(png_ptr, &row_pointers[y], 1);
}
}
#endif no_entire /* use only one output method */
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
* as well. Shouldn't be necessary in 1.1.0 and up as all the public
* chunks are supported and you can use png_set_unknown_chunks() to
* register unknown chunks into the info structure to be written out.
*/
/* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr);
#endif hilevel
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
as recommended in versions 1.0.5m and earlier of this example; if
libpng mallocs info_ptr->palette, libpng will free it). If you
allocated it with malloc() instead of png_malloc(), use free() instead
of png_free(). */
png_free(png_ptr, palette);
palette=NULL;
/* Similarly, if you png_malloced any data that you passed in with
png_set_something(), such as a hist or trans array, free it here,
when you can be sure that libpng is through with it. */
png_free(png_ptr, trans);
trans=NULL;
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, &info_ptr);
/* close the file */
fclose(fp);
/* that's it */
return (OK);
}
#endif /* if 0 */

Some files were not shown because too many files have changed in this diff Show More