mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
Added double-buffering for GUI, and PNG support
This commit is contained in:
parent
7c4dbdc036
commit
e82167b340
@ -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".
|
||||
|
||||
|
17
ChangeLog
17
ChangeLog
@ -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.
|
||||
|
||||
|
10
NEWS.txt
10
NEWS.txt
@ -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
|
||||
---
|
||||
|
||||
|
6
TODO.txt
6
TODO.txt
@ -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
2
all.h
@ -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>
|
||||
|
@ -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> ;
|
||||
}
|
||||
|
@ -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> ;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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_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,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
929
docs/script._tx
Normal 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 <std_disclaimer.h>
|
||||
<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 <= 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
6
fix.sh
@ -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
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*/
|
||||
@ -270,12 +270,27 @@ static JWidget convert_tag_to_widget(Tag *tag)
|
||||
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) {
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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);
|
||||
|
||||
@ -105,6 +109,16 @@ static void check_click(void)
|
||||
|
||||
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)
|
||||
{
|
||||
/* Update screen pointer. */
|
||||
@ -188,18 +202,45 @@ int ji_mouse_set_cursor(int type)
|
||||
|
||||
if (m_cursor == JI_CURSOR_NULL) {
|
||||
show_mouse(NULL);
|
||||
set_mouse_sprite (NULL);
|
||||
set_cursor(NULL, 0, 0);
|
||||
}
|
||||
else {
|
||||
show_mouse(NULL);
|
||||
if (theme->set_cursor)
|
||||
(*theme->set_cursor) (m_cursor);
|
||||
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)
|
||||
@ -212,14 +253,27 @@ bool ji_mouse_poll(void)
|
||||
poll_mouse();
|
||||
|
||||
m_b[0] = mouse_b;
|
||||
m_z[0] = mouse_z;
|
||||
|
||||
if (ji_screen == screen) {
|
||||
m_x[0] = mouse_x;
|
||||
m_y[0] = mouse_y;
|
||||
m_z[0] = mouse_z;
|
||||
}
|
||||
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]; }
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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,9 +217,14 @@ 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)
|
||||
@ -239,7 +249,8 @@ static void theme_init_widget (JWidget widget)
|
||||
|
||||
case JI_BOX:
|
||||
BORDER(0);
|
||||
widget->child_spacing = 2;
|
||||
/* widget->child_spacing = 2; */
|
||||
widget->child_spacing = 4;
|
||||
break;
|
||||
|
||||
case JI_BUTTON:
|
||||
@ -249,7 +260,8 @@ static void theme_init_widget (JWidget widget)
|
||||
|
||||
case JI_CHECK:
|
||||
BORDER(2);
|
||||
widget->child_spacing = 2;
|
||||
/* widget->child_spacing = 2; */
|
||||
widget->child_spacing = 4;
|
||||
break;
|
||||
|
||||
case JI_ENTRY:
|
||||
@ -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:
|
||||
|
23
makefile.gcc
23
makefile.gcc
@ -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
|
||||
|
58
makefile.lst
58
makefile.lst
@ -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)
|
||||
|
@ -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
|
||||
|
||||
######################################################################
|
||||
|
@ -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,7 +44,9 @@ 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,7 +127,7 @@ 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_set_static_size(wid_view, JI_SCREEN_W*9/10, JI_SCREEN_H*6/10);
|
||||
jwidget_show(wid_view);
|
||||
|
||||
jwindow_remap(wid_console);
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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];
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
@ -178,8 +178,8 @@ 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; \
|
||||
unsigned long *src = (unsigned long *)bmp->dat; \
|
||||
type *dst = (type *)image->dat; \
|
||||
for (i=0; i<pixels; i++) { \
|
||||
c = *src; \
|
||||
*dst = colfunc; \
|
||||
|
@ -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,7 +21,7 @@
|
||||
|
||||
struct Image;
|
||||
|
||||
void GUI_DrawText (void);
|
||||
void dialogs_draw_text(void);
|
||||
|
||||
struct Image *RenderText(const char *fontname, int size, int color, const char *text);
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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,
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
@ -224,7 +224,7 @@ static void button_font_command (JWidget widget)
|
||||
|
||||
static void button_lang_command(JWidget widget)
|
||||
{
|
||||
GUI_SelectLanguage (TRUE);
|
||||
dialogs_select_language(TRUE);
|
||||
}
|
||||
|
||||
static void set_label_font_text(void)
|
||||
|
@ -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 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);
|
||||
|
||||
|
@ -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
|
||||
@ -181,6 +181,7 @@ static void my_play_fli (const char *filename, bool loop, bool fullscreen,
|
||||
else
|
||||
blit(bmp, ji_screen, 0, 0, x, y, w, h);
|
||||
|
||||
jmanager_refresh_screen();
|
||||
gui_feedback();
|
||||
|
||||
do {
|
||||
|
@ -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;
|
||||
@ -43,11 +43,14 @@ void GUI_ScreenSaver (void)
|
||||
return;
|
||||
|
||||
/* hide the mouse */
|
||||
scare_mouse ();
|
||||
ji_mouse_set_cursor(JI_CURSOR_NULL);
|
||||
|
||||
/* get the current color palette */
|
||||
get_palette(backup);
|
||||
|
||||
/* flush drawing messages (useful when we are using double-buffering) */
|
||||
gui_feedback();
|
||||
|
||||
/* clear the screen */
|
||||
clear(ji_screen);
|
||||
|
||||
@ -122,17 +125,15 @@ void GUI_ScreenSaver (void)
|
||||
/* restore the color palette */
|
||||
set_palette(backup);
|
||||
|
||||
/* show the mouse cursor */
|
||||
unscare_mouse ();
|
||||
|
||||
/* wait while the user has pushed some mouse button */
|
||||
do {
|
||||
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 ();
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
@ -97,6 +97,10 @@ void GUI_Tips (bool forced)
|
||||
tips = tips_new();
|
||||
check = jcheck_new(_("Show me it in the start up"));
|
||||
|
||||
jwidget_set_static_size(button_close, 50, 0);
|
||||
jwidget_set_static_size(button_prev, 50, 0);
|
||||
jwidget_set_static_size(button_next, 50, 0);
|
||||
|
||||
jbutton_add_command_data(button_prev, prev_command, tips);
|
||||
jbutton_add_command_data(button_next, next_command, tips);
|
||||
|
||||
@ -173,6 +177,21 @@ static bool tips_msg_proc (JWidget widget, JMessage msg)
|
||||
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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
#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)
|
||||
|
@ -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
691
src/file/png_file.c
Normal 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; */
|
||||
/* } */
|
@ -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";
|
||||
|
||||
|
@ -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,14 +124,15 @@ 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;
|
||||
}
|
||||
|
||||
while (screen_scaling > 0) {
|
||||
/* try original mode */
|
||||
set_color_depth(bpp);
|
||||
if (set_gfx_mode(autodetect, w, h, 0, 0) < 0) {
|
||||
@ -127,12 +141,20 @@ int init_module_gui(void)
|
||||
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();
|
||||
@ -171,12 +193,12 @@ int init_module_gui(void)
|
||||
|
||||
void exit_module_gui(void)
|
||||
{
|
||||
#ifdef GUI_DOUBLE_BUFFERED
|
||||
if (double_buffering) {
|
||||
BITMAP *old_bmp = ji_screen;
|
||||
ji_set_screen(screen);
|
||||
if (old_bmp && old_bmp != screen)
|
||||
destroy_bitmap(old_bmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
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,7 +248,7 @@ void GUI_Refresh(Sprite *sprite)
|
||||
}
|
||||
}
|
||||
|
||||
void run_gui(void)
|
||||
void gui_run(void)
|
||||
{
|
||||
jmanager_run(manager);
|
||||
}
|
||||
@ -249,12 +274,21 @@ 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
|
||||
/* 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);
|
||||
}
|
||||
@ -263,7 +297,7 @@ void gui_feedback(void)
|
||||
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
|
||||
if (double_buffering) {
|
||||
BITMAP *old_bmp = ji_screen;
|
||||
ji_set_screen(create_bitmap(SCREEN_W, SCREEN_H));
|
||||
ji_set_screen(create_bitmap(SCREEN_W / screen_scaling,
|
||||
SCREEN_H / screen_scaling));
|
||||
if (old_bmp && old_bmp != screen)
|
||||
destroy_bitmap(old_bmp);
|
||||
#else
|
||||
}
|
||||
else {
|
||||
ji_set_screen(screen);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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; */
|
||||
};
|
||||
|
@ -309,25 +309,25 @@ int set_gfx (const char *card, int w, int h, int depth);
|
||||
|
||||
/* dialogs/... */
|
||||
|
||||
void GUI_About (void);
|
||||
void GUI_ColorCurve (void);
|
||||
void GUI_ConvolutionMatrix (void);
|
||||
void GUI_DrawText (void);
|
||||
void dialogs_about(void);
|
||||
void dialogs_color_curve(void);
|
||||
void dialogs_convolution_matrix(void);
|
||||
void dialogs_draw_text(void);
|
||||
void switch_between_film_and_sprite_editor(void);
|
||||
void GUI_FrameLength (int frpos);
|
||||
void GUI_InvertColor (void);
|
||||
void GUI_MapGen (void);
|
||||
void GUI_MaskColor (void);
|
||||
void GUI_MaskRepository (void);
|
||||
void GUI_MedianFilter (void);
|
||||
void GUI_Options (void);
|
||||
void show_palette_editor (void);
|
||||
void GUI_ReplaceColor (void);
|
||||
void GUI_ScreenSaver (void);
|
||||
void GUI_SelectLanguage (bool force);
|
||||
void GUI_Tips (bool forced);
|
||||
void GUI_ToolsConfiguration (void);
|
||||
void GUI_VectorMap (void);
|
||||
void dialogs_frame_length (int frpos);
|
||||
void dialogs_invert_color(void);
|
||||
void dialogs_mapgen(void);
|
||||
void dialogs_mask_color(void);
|
||||
void dialogs_mask_repository(void);
|
||||
void dialogs_median_filter(void);
|
||||
void dialogs_options(void);
|
||||
void dialogs_palette_editor(void);
|
||||
void dialogs_replace_color(void);
|
||||
void dialogs_screen_saver(void);
|
||||
void dialogs_select_language(bool force);
|
||||
void dialogs_tips(bool forced);
|
||||
void dialogs_tools_configuration(void);
|
||||
void dialogs_vector_map(void);
|
||||
|
||||
/* dialogs/view.c */
|
||||
|
||||
@ -500,7 +500,6 @@ void mask_crop (Mask *mask, Image *image);
|
||||
|
||||
/* Path *************************************************************/
|
||||
|
||||
|
||||
#define PATH_JOIN_MITER
|
||||
#define PATH_JOIN_ROUND
|
||||
#define PATH_JOIN_BEVEL
|
||||
|
@ -1393,27 +1393,27 @@ static int bind_set_gfx (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bind_GUI_About (lua_State *L)
|
||||
static int bind_dialogs_about(lua_State *L)
|
||||
{
|
||||
GUI_About ();
|
||||
dialogs_about();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_ColorCurve (lua_State *L)
|
||||
static int bind_dialogs_color_curve(lua_State *L)
|
||||
{
|
||||
GUI_ColorCurve ();
|
||||
dialogs_color_curve();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_ConvolutionMatrix (lua_State *L)
|
||||
static int bind_dialogs_convolution_matrix(lua_State *L)
|
||||
{
|
||||
GUI_ConvolutionMatrix ();
|
||||
dialogs_convolution_matrix();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_DrawText (lua_State *L)
|
||||
static int bind_dialogs_draw_text(lua_State *L)
|
||||
{
|
||||
GUI_DrawText ();
|
||||
dialogs_draw_text();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1423,93 +1423,85 @@ static int bind_switch_between_film_and_sprite_editor (lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_FrameLength (lua_State *L)
|
||||
static int bind_dialogs_invert_color(lua_State *L)
|
||||
{
|
||||
int frpos;
|
||||
GetArg (1, frpos, int, number);
|
||||
GUI_FrameLength (frpos);
|
||||
dialogs_invert_color();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_InvertColor (lua_State *L)
|
||||
static int bind_dialogs_mapgen(lua_State *L)
|
||||
{
|
||||
GUI_InvertColor ();
|
||||
dialogs_mapgen();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_MapGen (lua_State *L)
|
||||
static int bind_dialogs_mask_color(lua_State *L)
|
||||
{
|
||||
GUI_MapGen ();
|
||||
dialogs_mask_color();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_MaskColor (lua_State *L)
|
||||
static int bind_dialogs_mask_repository(lua_State *L)
|
||||
{
|
||||
GUI_MaskColor ();
|
||||
dialogs_mask_repository();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_MaskRepository (lua_State *L)
|
||||
static int bind_dialogs_median_filter(lua_State *L)
|
||||
{
|
||||
GUI_MaskRepository ();
|
||||
dialogs_median_filter();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_MedianFilter (lua_State *L)
|
||||
static int bind_dialogs_options(lua_State *L)
|
||||
{
|
||||
GUI_MedianFilter ();
|
||||
dialogs_options();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_Options (lua_State *L)
|
||||
static int bind_dialogs_palette_editor(lua_State *L)
|
||||
{
|
||||
GUI_Options ();
|
||||
dialogs_palette_editor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_show_palette_editor (lua_State *L)
|
||||
static int bind_dialogs_replace_color(lua_State *L)
|
||||
{
|
||||
show_palette_editor ();
|
||||
dialogs_replace_color();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_ReplaceColor (lua_State *L)
|
||||
static int bind_dialogs_screen_saver(lua_State *L)
|
||||
{
|
||||
GUI_ReplaceColor ();
|
||||
dialogs_screen_saver();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_ScreenSaver (lua_State *L)
|
||||
{
|
||||
GUI_ScreenSaver ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_SelectLanguage (lua_State *L)
|
||||
static int bind_dialogs_select_language(lua_State *L)
|
||||
{
|
||||
bool force;
|
||||
GetArg(1, force, bool, boolean);
|
||||
GUI_SelectLanguage (force);
|
||||
dialogs_select_language(force);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_Tips (lua_State *L)
|
||||
static int bind_dialogs_tips(lua_State *L)
|
||||
{
|
||||
bool forced;
|
||||
GetArg(1, forced, bool, boolean);
|
||||
GUI_Tips (forced);
|
||||
dialogs_tips(forced);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_ToolsConfiguration (lua_State *L)
|
||||
static int bind_dialogs_tools_configuration(lua_State *L)
|
||||
{
|
||||
GUI_ToolsConfiguration ();
|
||||
dialogs_tools_configuration();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bind_GUI_VectorMap (lua_State *L)
|
||||
static int bind_dialogs_vector_map(lua_State *L)
|
||||
{
|
||||
GUI_VectorMap ();
|
||||
dialogs_vector_map();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5881,25 +5873,24 @@ const luaL_reg bindings_routines[] = {
|
||||
{ "rec_screen_off", bind_rec_screen_off },
|
||||
{ "screen_shot", bind_screen_shot },
|
||||
{ "set_gfx", bind_set_gfx },
|
||||
{ "GUI_About", bind_GUI_About },
|
||||
{ "GUI_ColorCurve", bind_GUI_ColorCurve },
|
||||
{ "GUI_ConvolutionMatrix", bind_GUI_ConvolutionMatrix },
|
||||
{ "GUI_DrawText", bind_GUI_DrawText },
|
||||
{ "dialogs_about", bind_dialogs_about },
|
||||
{ "dialogs_color_curve", bind_dialogs_color_curve },
|
||||
{ "dialogs_convolution_matrix", bind_dialogs_convolution_matrix },
|
||||
{ "dialogs_draw_text", bind_dialogs_draw_text },
|
||||
{ "switch_between_film_and_sprite_editor", bind_switch_between_film_and_sprite_editor },
|
||||
{ "GUI_FrameLength", bind_GUI_FrameLength },
|
||||
{ "GUI_InvertColor", bind_GUI_InvertColor },
|
||||
{ "GUI_MapGen", bind_GUI_MapGen },
|
||||
{ "GUI_MaskColor", bind_GUI_MaskColor },
|
||||
{ "GUI_MaskRepository", bind_GUI_MaskRepository },
|
||||
{ "GUI_MedianFilter", bind_GUI_MedianFilter },
|
||||
{ "GUI_Options", bind_GUI_Options },
|
||||
{ "show_palette_editor", bind_show_palette_editor },
|
||||
{ "GUI_ReplaceColor", bind_GUI_ReplaceColor },
|
||||
{ "GUI_ScreenSaver", bind_GUI_ScreenSaver },
|
||||
{ "GUI_SelectLanguage", bind_GUI_SelectLanguage },
|
||||
{ "GUI_Tips", bind_GUI_Tips },
|
||||
{ "GUI_ToolsConfiguration", bind_GUI_ToolsConfiguration },
|
||||
{ "GUI_VectorMap", bind_GUI_VectorMap },
|
||||
{ "dialogs_invert_color", bind_dialogs_invert_color },
|
||||
{ "dialogs_mapgen", bind_dialogs_mapgen },
|
||||
{ "dialogs_mask_color", bind_dialogs_mask_color },
|
||||
{ "dialogs_mask_repository", bind_dialogs_mask_repository },
|
||||
{ "dialogs_median_filter", bind_dialogs_median_filter },
|
||||
{ "dialogs_options", bind_dialogs_options },
|
||||
{ "dialogs_palette_editor", bind_dialogs_palette_editor },
|
||||
{ "dialogs_replace_color", bind_dialogs_replace_color },
|
||||
{ "dialogs_screen_saver", bind_dialogs_screen_saver },
|
||||
{ "dialogs_select_language", bind_dialogs_select_language },
|
||||
{ "dialogs_tips", bind_dialogs_tips },
|
||||
{ "dialogs_tools_configuration", bind_dialogs_tools_configuration },
|
||||
{ "dialogs_vector_map", bind_dialogs_vector_map },
|
||||
{ "view_tiled", bind_view_tiled },
|
||||
{ "view_normal", bind_view_normal },
|
||||
{ "view_fullscreen", bind_view_fullscreen },
|
||||
|
@ -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 (); */
|
||||
|
@ -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;
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#ifndef USE_PRECOMPILED_HEADER
|
||||
|
||||
#include <allegro/file.h>
|
||||
#include <allegro.h>
|
||||
|
||||
#include "raster/image.h"
|
||||
#include "raster/mask.h"
|
||||
@ -31,8 +31,14 @@
|
||||
/* loads a MSK file (Animator and Animator Pro format) */
|
||||
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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -124,9 +124,6 @@ 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);
|
||||
|
||||
@ -135,7 +132,7 @@ int set_gfx(const char *_card, int w, int h, int depth)
|
||||
}
|
||||
|
||||
/* setup mouse */
|
||||
show_mouse(ji_screen);
|
||||
/* show_mouse(ji_screen); */
|
||||
_setup_mouse_speed();
|
||||
|
||||
/* redraw top window */
|
||||
|
@ -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
|
||||
@ -54,7 +54,8 @@ 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++)
|
||||
@ -112,5 +113,5 @@ static int group_change_signal (JWidget widget, int user_data)
|
||||
|
||||
static void conf_command(JWidget widget)
|
||||
{
|
||||
GUI_ToolsConfiguration ();
|
||||
dialogs_tools_configuration();
|
||||
}
|
||||
|
18
third_party/README.txt
vendored
18
third_party/README.txt
vendored
@ -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
109
third_party/libpng/LICENSE
vendored
Normal 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
263
third_party/libpng/README
vendored
Normal 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
24
third_party/libpng/TODO
vendored
Normal 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
55
third_party/libpng/Y2KINFO
vendored
Normal 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
814
third_party/libpng/example.c
vendored
Normal 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 */
|
2851
third_party/libpng/libpng-1.2.20.txt
vendored
Normal file
2851
third_party/libpng/libpng-1.2.20.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
798
third_party/libpng/png.c
vendored
Normal file
798
third_party/libpng/png.c
vendored
Normal file
@ -0,0 +1,798 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.2.19 August 19, 2007
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#define PNG_NO_EXTERN
|
||||
#include "png.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_2_20 Your_png_h_is_not_version_1_2_20;
|
||||
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h. */
|
||||
|
||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||
PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* png_sig was changed to a function in version 1.0.5c */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Invoke global declarations for constant strings for known chunk types */
|
||||
PNG_IHDR;
|
||||
PNG_IDAT;
|
||||
PNG_IEND;
|
||||
PNG_PLTE;
|
||||
PNG_bKGD;
|
||||
PNG_cHRM;
|
||||
PNG_gAMA;
|
||||
PNG_hIST;
|
||||
PNG_iCCP;
|
||||
PNG_iTXt;
|
||||
PNG_oFFs;
|
||||
PNG_pCAL;
|
||||
PNG_sCAL;
|
||||
PNG_pHYs;
|
||||
PNG_sBIT;
|
||||
PNG_sPLT;
|
||||
PNG_sRGB;
|
||||
PNG_tEXt;
|
||||
PNG_tIME;
|
||||
PNG_tRNS;
|
||||
PNG_zTXt;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* start of interlace block */
|
||||
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* offset to next interlace block */
|
||||
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* start of interlace block in the y direction */
|
||||
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* offset to next interlace block in the y direction */
|
||||
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* Height of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
|
||||
/* Mask to determine which pixels are valid in a pass */
|
||||
PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
|
||||
/* Mask to determine which pixels to overwrite while displaying */
|
||||
PNG_CONST int FARDATA png_pass_dsp_mask[]
|
||||
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_USE_GLOBAL_ARRAYS */
|
||||
|
||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||
* of the PNG file signature. If the PNG data is embedded into another
|
||||
* stream we can set num_bytes = 8 so that libpng will not attempt to read
|
||||
* or write any of the magic bytes before it starts on the IHDR.
|
||||
*/
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
png_debug(1, "in png_set_sig_bytes\n");
|
||||
if (num_bytes > 8)
|
||||
png_error(png_ptr, "Too many bytes for PNG signature.");
|
||||
|
||||
png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
|
||||
}
|
||||
|
||||
/* Checks whether the supplied bytes match the PNG signature. We allow
|
||||
* checking less than the full 8-byte signature so that those apps that
|
||||
* already read the first few bytes of a file to determine the file type
|
||||
* can simply check the remaining bytes for extra assurance. Returns
|
||||
* an integer less than, equal to, or greater than zero if sig is found,
|
||||
* respectively, to be less than, to match, or be greater than the correct
|
||||
* PNG signature (this is the same behaviour as strcmp, memcmp, etc).
|
||||
*/
|
||||
int PNGAPI
|
||||
png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
if (num_to_check > 8)
|
||||
num_to_check = 8;
|
||||
else if (num_to_check < 1)
|
||||
return (-1);
|
||||
|
||||
if (start > 7)
|
||||
return (-1);
|
||||
|
||||
if (start + num_to_check > 8)
|
||||
num_to_check = 8 - start;
|
||||
|
||||
return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));
|
||||
}
|
||||
|
||||
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||
/* (Obsolete) function to check signature bytes. It does not allow one
|
||||
* to check a partial signature. This function might be removed in the
|
||||
* future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG.
|
||||
*/
|
||||
int PNGAPI
|
||||
png_check_sig(png_bytep sig, int num)
|
||||
{
|
||||
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
/* Function to allocate memory for zlib and clear it to 0. */
|
||||
#ifdef PNG_1_0_X
|
||||
voidpf PNGAPI
|
||||
#else
|
||||
voidpf /* private */
|
||||
#endif
|
||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
png_voidp ptr;
|
||||
png_structp p=(png_structp)png_ptr;
|
||||
png_uint_32 save_flags=p->flags;
|
||||
png_uint_32 num_bytes;
|
||||
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (items > PNG_UINT_32_MAX/size)
|
||||
{
|
||||
png_warning (p, "Potential overflow in png_zalloc()");
|
||||
return (NULL);
|
||||
}
|
||||
num_bytes = (png_uint_32)items * size;
|
||||
|
||||
p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
|
||||
p->flags=save_flags;
|
||||
|
||||
#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO)
|
||||
if (ptr == NULL)
|
||||
return ((voidpf)ptr);
|
||||
|
||||
if (num_bytes > (png_uint_32)0x8000L)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
|
||||
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
|
||||
}
|
||||
else
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)num_bytes);
|
||||
}
|
||||
#endif
|
||||
return ((voidpf)ptr);
|
||||
}
|
||||
|
||||
/* function to free memory for zlib */
|
||||
#ifdef PNG_1_0_X
|
||||
void PNGAPI
|
||||
#else
|
||||
void /* private */
|
||||
#endif
|
||||
png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
{
|
||||
png_free((png_structp)png_ptr, (png_voidp)ptr);
|
||||
}
|
||||
|
||||
/* Reset the CRC variable to 32 bits of 1's. Care must be taken
|
||||
* in case CRC is > 32 bits to leave the top bits 0.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_reset_crc(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->crc = crc32(0, Z_NULL, 0);
|
||||
}
|
||||
|
||||
/* Calculate the CRC over a section of data. We can only pass as
|
||||
* much data to this routine as the largest single buffer size. We
|
||||
* also check that this data will actually be used before going to the
|
||||
* trouble of calculating it.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
{
|
||||
int need_crc = 1;
|
||||
|
||||
if (png_ptr->chunk_name[0] & 0x20) /* ancillary */
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
|
||||
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
||||
need_crc = 0;
|
||||
}
|
||||
else /* critical */
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
|
||||
need_crc = 0;
|
||||
}
|
||||
|
||||
if (need_crc)
|
||||
png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length);
|
||||
}
|
||||
|
||||
/* Allocate the memory for an info_struct for the application. We don't
|
||||
* really need the png_ptr, but it could potentially be useful in the
|
||||
* future. This should be used in favour of malloc(png_sizeof(png_info))
|
||||
* and png_info_init() so that applications that want to use a shared
|
||||
* libpng don't have to be recompiled if png_info changes size.
|
||||
*/
|
||||
png_infop PNGAPI
|
||||
png_create_info_struct(png_structp png_ptr)
|
||||
{
|
||||
png_infop info_ptr;
|
||||
|
||||
png_debug(1, "in png_create_info_struct\n");
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
|
||||
png_ptr->malloc_fn, png_ptr->mem_ptr);
|
||||
#else
|
||||
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
|
||||
#endif
|
||||
if (info_ptr != NULL)
|
||||
png_info_init_3(&info_ptr, png_sizeof(png_info));
|
||||
|
||||
return (info_ptr);
|
||||
}
|
||||
|
||||
/* This function frees the memory associated with a single info struct.
|
||||
* Normally, one would use either png_destroy_read_struct() or
|
||||
* png_destroy_write_struct() to free an info struct, but this may be
|
||||
* useful for some applications.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
png_infop info_ptr = NULL;
|
||||
if(png_ptr == NULL) return;
|
||||
|
||||
png_debug(1, "in png_destroy_info_struct\n");
|
||||
if (info_ptr_ptr != NULL)
|
||||
info_ptr = *info_ptr_ptr;
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_info_destroy(png_ptr, info_ptr);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn,
|
||||
png_ptr->mem_ptr);
|
||||
#else
|
||||
png_destroy_struct((png_voidp)info_ptr);
|
||||
#endif
|
||||
*info_ptr_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the info structure. This is now an internal function (0.89)
|
||||
* and applications using it are urged to use png_create_info_struct()
|
||||
* instead.
|
||||
*/
|
||||
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||
#undef png_info_init
|
||||
void PNGAPI
|
||||
png_info_init(png_infop info_ptr)
|
||||
{
|
||||
/* We only come here via pre-1.0.12-compiled applications */
|
||||
png_info_init_3(&info_ptr, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
||||
{
|
||||
png_infop info_ptr = *ptr_ptr;
|
||||
|
||||
if(info_ptr == NULL) return;
|
||||
|
||||
png_debug(1, "in png_info_init_3\n");
|
||||
|
||||
if(png_sizeof(png_info) > png_info_struct_size)
|
||||
{
|
||||
png_destroy_struct(info_ptr);
|
||||
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
|
||||
*ptr_ptr = info_ptr;
|
||||
}
|
||||
|
||||
/* set everything to 0 */
|
||||
png_memset(info_ptr, 0, png_sizeof (png_info));
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
void PNGAPI
|
||||
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||
int freer, png_uint_32 mask)
|
||||
{
|
||||
png_debug(1, "in png_data_freer\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if(freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||
info_ptr->free_me |= mask;
|
||||
else if(freer == PNG_USER_WILL_FREE_DATA)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Unknown freer parameter in png_data_freer.");
|
||||
}
|
||||
#endif
|
||||
|
||||
void PNGAPI
|
||||
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
|
||||
int num)
|
||||
{
|
||||
png_debug(1, "in png_free_data\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
/* free text item num or (if num == -1) all text items */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_TEXT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if (info_ptr->text && info_ptr->text[num].key)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[num].key);
|
||||
info_ptr->text[num].key = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
info_ptr->num_text=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
/* free any tRNS entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->trans);
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
#ifndef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
info_ptr->trans = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
/* free any sCAL entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_SCAL)
|
||||
#endif
|
||||
{
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->scal_s_width);
|
||||
png_free(png_ptr, info_ptr->scal_s_height);
|
||||
info_ptr->scal_s_width = NULL;
|
||||
info_ptr->scal_s_height = NULL;
|
||||
#endif
|
||||
info_ptr->valid &= ~PNG_INFO_sCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
/* free any pCAL entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_PCAL)
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
png_free(png_ptr, info_ptr->pcal_units);
|
||||
info_ptr->pcal_purpose = NULL;
|
||||
info_ptr->pcal_units = NULL;
|
||||
if (info_ptr->pcal_params != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
info_ptr->pcal_params[i]=NULL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
info_ptr->pcal_params = NULL;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_pCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
/* free any iCCP entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_ICCP)
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->iccp_name);
|
||||
png_free(png_ptr, info_ptr->iccp_profile);
|
||||
info_ptr->iccp_name = NULL;
|
||||
info_ptr->iccp_profile = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_iCCP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
/* free a given sPLT entry, or (if num == -1) all sPLT entries */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_SPLT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if(info_ptr->splt_palettes)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
|
||||
info_ptr->splt_palettes[num].name = NULL;
|
||||
info_ptr->splt_palettes[num].entries = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(info_ptr->splt_palettes_num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes = NULL;
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_sPLT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_ptr->unknown_chunk.data)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_UNKN)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if(info_ptr->unknown_chunks)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
|
||||
info_ptr->unknown_chunks[num].data = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
if(info_ptr->unknown_chunks_num)
|
||||
{
|
||||
for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks = NULL;
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
/* free any hIST entry */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->hist);
|
||||
info_ptr->hist = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_hIST;
|
||||
#ifndef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* free any PLTE entry that was internally allocated */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
|
||||
#else
|
||||
if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
|
||||
#endif
|
||||
{
|
||||
png_zfree(png_ptr, info_ptr->palette);
|
||||
info_ptr->palette = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_PLTE;
|
||||
#ifndef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
|
||||
#endif
|
||||
info_ptr->num_palette = 0;
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
/* free any image bits attached to the info structure */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
|
||||
#else
|
||||
if (mask & PNG_FREE_ROWS)
|
||||
#endif
|
||||
{
|
||||
if(info_ptr->row_pointers)
|
||||
{
|
||||
int row;
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->row_pointers[row]);
|
||||
info_ptr->row_pointers[row]=NULL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->row_pointers=NULL;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_IDAT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if(num == -1)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is an internal routine to free any memory that the info struct is
|
||||
* pointing to before re-using it or freeing the struct itself. Recall
|
||||
* that png_free() checks for NULL pointers for us.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_info_destroy\n");
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_info_init_3(&info_ptr, png_sizeof(png_info));
|
||||
}
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
|
||||
/* This function returns a pointer to the io_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy() or png_read_destroy() are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
return (png_ptr->io_ptr);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
/* Initialize the default input/output functions for the PNG file. If you
|
||||
* use your own read or write routines, you can call either png_set_read_fn()
|
||||
* or png_set_write_fn() instead of png_init_io(). If you have defined
|
||||
* PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
|
||||
* necessarily available.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||
{
|
||||
png_debug(1, "in png_init_io\n");
|
||||
if(png_ptr == NULL) return;
|
||||
png_ptr->io_ptr = (png_voidp)fp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
/* Convert the supplied time into an RFC 1123 string suitable for use in
|
||||
* a "Creation Time" or other text-based time string.
|
||||
*/
|
||||
png_charp PNGAPI
|
||||
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
{
|
||||
static PNG_CONST char short_months[12][4] =
|
||||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr->time_buffer == NULL)
|
||||
{
|
||||
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
||||
png_sizeof(char)));
|
||||
}
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
{
|
||||
wchar_t time_buf[29];
|
||||
wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
|
||||
NULL, NULL);
|
||||
}
|
||||
#else
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
char near_time_buf[29];
|
||||
png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
png_memcpy(png_ptr->time_buffer, near_time_buf,
|
||||
29*png_sizeof(char));
|
||||
}
|
||||
#else
|
||||
png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
#endif
|
||||
#endif /* _WIN32_WCE */
|
||||
return ((png_charp)png_ptr->time_buffer);
|
||||
}
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
|
||||
png_charp PNGAPI
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||
return ((png_charp) "\n libpng version 1.2.20 - September 8, 2007\n\
|
||||
Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\n\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
||||
}
|
||||
|
||||
/* The following return the library version as a short string in the
|
||||
* format 1.0.0 through 99.99.99zz. To get the version of *.h files
|
||||
* used with your application, print out PNG_LIBPNG_VER_STRING, which
|
||||
* is defined in png.h.
|
||||
* Note: now there is no difference between png_get_libpng_ver() and
|
||||
* png_get_header_ver(). Due to the version_nn_nn_nn typedef guard,
|
||||
* it is guaranteed that png.c uses the correct version of png.h.
|
||||
*/
|
||||
png_charp PNGAPI
|
||||
png_get_libpng_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||
}
|
||||
|
||||
png_charp PNGAPI
|
||||
png_get_header_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.h files used when building libpng */
|
||||
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||
}
|
||||
|
||||
png_charp PNGAPI
|
||||
png_get_header_version(png_structp png_ptr)
|
||||
{
|
||||
/* Returns longer string containing both version and date */
|
||||
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||
return ((png_charp) PNG_HEADER_VERSION_STRING
|
||||
#ifndef PNG_READ_SUPPORTED
|
||||
" (NO READ SUPPORT)"
|
||||
#endif
|
||||
"\n");
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int PNGAPI
|
||||
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
||||
{
|
||||
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||
int i;
|
||||
png_bytep p;
|
||||
if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
|
||||
return 0;
|
||||
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
||||
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
||||
if (!png_memcmp(chunk_name, p, 4))
|
||||
return ((int)*(p+4));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function, added to libpng-1.0.6g, is untested. */
|
||||
int PNGAPI
|
||||
png_reset_zstream(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL) return Z_STREAM_ERROR;
|
||||
return (inflateReset(&png_ptr->zstream));
|
||||
}
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
|
||||
/* This function was added to libpng-1.0.7 */
|
||||
png_uint_32 PNGAPI
|
||||
png_access_version_number(void)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
return((png_uint_32) PNG_LIBPNG_VER);
|
||||
}
|
||||
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||
#if !defined(PNG_1_0_X)
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
int PNGAPI
|
||||
png_mmx_support(void)
|
||||
{
|
||||
/* obsolete, to be removed from libpng-1.4.0 */
|
||||
return -1;
|
||||
}
|
||||
#endif /* PNG_1_0_X */
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
#ifdef PNG_SIZE_T
|
||||
/* Added at libpng version 1.2.6 */
|
||||
PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
|
||||
png_size_t PNGAPI
|
||||
png_convert_size(size_t size)
|
||||
{
|
||||
if (size > (png_size_t)-1)
|
||||
PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */
|
||||
return ((png_size_t)size);
|
||||
}
|
||||
#endif /* PNG_SIZE_T */
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
3531
third_party/libpng/png.h
vendored
Normal file
3531
third_party/libpng/png.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1480
third_party/libpng/pngconf.h
vendored
Normal file
1480
third_party/libpng/pngconf.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
341
third_party/libpng/pngerror.c
vendored
Normal file
341
third_party/libpng/pngerror.c
vendored
Normal file
@ -0,0 +1,341 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.2.20 September 8, 2007
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all error handling. Users who
|
||||
* need special error handling are expected to write replacement functions
|
||||
* and use png_set_error_fn() to use those functions. See the instructions
|
||||
* at each function.
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_default_error PNGARG((png_structp png_ptr,
|
||||
png_const_charp error_message));
|
||||
#ifndef PNG_NO_WARNINGS
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_NO_WARNINGS */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
* should not be changed. If there is a need to handle errors differently,
|
||||
* you should supply a replacement error function and use png_set_error_fn()
|
||||
* to replace the error function at run-time.
|
||||
*/
|
||||
#ifndef PNG_NO_ERROR_TEXT
|
||||
void PNGAPI
|
||||
png_error(png_structp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
char msg[16];
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
{
|
||||
if (*error_message == '#')
|
||||
{
|
||||
int offset;
|
||||
for (offset=1; offset<15; offset++)
|
||||
if (*(error_message+offset) == ' ')
|
||||
break;
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<offset-1; i++)
|
||||
msg[i]=error_message[i+1];
|
||||
msg[i]='\0';
|
||||
error_message=msg;
|
||||
}
|
||||
else
|
||||
error_message+=offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
msg[0]='0';
|
||||
msg[1]='\0';
|
||||
error_message=msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, error_message);
|
||||
}
|
||||
#else
|
||||
void PNGAPI
|
||||
png_err(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_ptr, '\0');
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, '\0');
|
||||
}
|
||||
#endif /* PNG_NO_ERROR_TEXT */
|
||||
|
||||
#ifndef PNG_NO_WARNINGS
|
||||
/* This function is called whenever there is a non-fatal error. This function
|
||||
* should not be changed. If there is a need to handle warnings differently,
|
||||
* you should supply a replacement warning function and use
|
||||
* png_set_error_fn() to replace the warning function at run-time.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
int offset = 0;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == '#')
|
||||
{
|
||||
for (offset=1; offset<15; offset++)
|
||||
if (*(warning_message+offset) == ' ')
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_ptr, warning_message+offset);
|
||||
}
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message+offset);
|
||||
}
|
||||
#endif /* PNG_NO_WARNINGS */
|
||||
|
||||
|
||||
/* These utilities are used internally to build an error message that relates
|
||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||
* this is used to prefix the message. The message is limited in length
|
||||
* to 63 bytes, the name characters are output as hex digits wrapped in []
|
||||
* if the character is invalid.
|
||||
*/
|
||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||
static PNG_CONST char png_digit[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
int iout = 0, iin = 0;
|
||||
|
||||
while (iin < 4)
|
||||
{
|
||||
int c = png_ptr->chunk_name[iin++];
|
||||
if (isnonalpha(c))
|
||||
{
|
||||
buffer[iout++] = '[';
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
buffer[iout++] = png_digit[c & 0x0f];
|
||||
buffer[iout++] = ']';
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (png_byte)c;
|
||||
}
|
||||
}
|
||||
|
||||
if (error_message == NULL)
|
||||
buffer[iout] = 0;
|
||||
else
|
||||
{
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
png_strncpy(buffer+iout, error_message, 63);
|
||||
buffer[iout+63] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
char msg[18+64];
|
||||
if (png_ptr == NULL)
|
||||
png_error(png_ptr, error_message);
|
||||
else
|
||||
{
|
||||
png_format_buffer(png_ptr, msg, error_message);
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
|
||||
|
||||
#ifndef PNG_NO_WARNINGS
|
||||
void PNGAPI
|
||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
char msg[18+64];
|
||||
if (png_ptr == NULL)
|
||||
png_warning(png_ptr, warning_message);
|
||||
else
|
||||
{
|
||||
png_format_buffer(png_ptr, msg, warning_message);
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_NO_WARNINGS */
|
||||
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||
* function is used by default, or if the program supplies NULL for the
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_error(png_structp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*error_message == '#')
|
||||
{
|
||||
int offset;
|
||||
char error_number[16];
|
||||
for (offset=0; offset<15; offset++)
|
||||
{
|
||||
error_number[offset] = *(error_message+offset+1);
|
||||
if (*(error_message+offset) == ' ')
|
||||
break;
|
||||
}
|
||||
if((offset > 1) && (offset < 15))
|
||||
{
|
||||
error_number[offset-1]='\0';
|
||||
fprintf(stderr, "libpng error no. %s: %s\n", error_number,
|
||||
error_message+offset);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
fprintf(stderr, "libpng error: %s\n", error_message);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr)
|
||||
{
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf jmpbuf;
|
||||
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||
longjmp(jmpbuf, 1);
|
||||
}
|
||||
# else
|
||||
longjmp(png_ptr->jmpbuf, 1);
|
||||
# endif
|
||||
}
|
||||
#else
|
||||
PNG_ABORT();
|
||||
#endif
|
||||
#ifdef PNG_NO_CONSOLE_IO
|
||||
error_message = error_message; /* make compiler happy */
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef PNG_NO_WARNINGS
|
||||
/* This function is called when there is a warning, but the library thinks
|
||||
* it can continue anyway. Replacement functions don't have to do anything
|
||||
* here if you don't want them to. In the default configuration, png_ptr is
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*warning_message == '#')
|
||||
{
|
||||
int offset;
|
||||
char warning_number[16];
|
||||
for (offset=0; offset<15; offset++)
|
||||
{
|
||||
warning_number[offset]=*(warning_message+offset+1);
|
||||
if (*(warning_message+offset) == ' ')
|
||||
break;
|
||||
}
|
||||
if((offset > 1) && (offset < 15))
|
||||
{
|
||||
warning_number[offset-1]='\0';
|
||||
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
|
||||
warning_message+offset);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
||||
#else
|
||||
warning_message = warning_message; /* make compiler happy */
|
||||
#endif
|
||||
png_ptr = png_ptr; /* make compiler happy */
|
||||
}
|
||||
#endif /* PNG_NO_WARNINGS */
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
png_ptr->error_fn = error_fn;
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
}
|
||||
|
||||
|
||||
/* This function returns a pointer to the error_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_error_ptr(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
}
|
||||
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if(png_ptr != NULL)
|
||||
{
|
||||
png_ptr->flags &=
|
||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
101
third_party/libpng/pnggccrd.c
vendored
Normal file
101
third_party/libpng/pnggccrd.c
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/* pnggccrd.c was removed from libpng-1.2.20. */
|
||||
|
||||
/* This code snippet is for use by configure's compilation test. */
|
||||
|
||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
|
||||
defined(PNG_MMX_CODE_SUPPORTED)
|
||||
int PNGAPI png_dummy_mmx_support(void);
|
||||
|
||||
static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested
|
||||
|
||||
int PNGAPI
|
||||
png_dummy_mmx_support(void) __attribute__((noinline));
|
||||
|
||||
int PNGAPI
|
||||
png_dummy_mmx_support(void)
|
||||
{
|
||||
int result;
|
||||
#if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck
|
||||
__asm__ __volatile__ (
|
||||
#if defined(__x86_64__)
|
||||
"pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction
|
||||
"pushq %%rcx \n\t" // so does rcx...
|
||||
"pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux)
|
||||
"pushfq \n\t" // save Eflag to stack
|
||||
"popq %%rax \n\t" // get Eflag from stack into rax
|
||||
"movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx
|
||||
"xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
|
||||
"pushq %%rax \n\t" // save modified Eflag back to stack
|
||||
"popfq \n\t" // restore modified value to Eflag reg
|
||||
"pushfq \n\t" // save Eflag to stack
|
||||
"popq %%rax \n\t" // get Eflag from stack
|
||||
"pushq %%rcx \n\t" // save original Eflag to stack
|
||||
"popfq \n\t" // restore original Eflag
|
||||
#else
|
||||
"pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction
|
||||
"pushl %%ecx \n\t" // so does ecx...
|
||||
"pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux)
|
||||
"pushfl \n\t" // save Eflag to stack
|
||||
"popl %%eax \n\t" // get Eflag from stack into eax
|
||||
"movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx
|
||||
"xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
|
||||
"pushl %%eax \n\t" // save modified Eflag back to stack
|
||||
"popfl \n\t" // restore modified value to Eflag reg
|
||||
"pushfl \n\t" // save Eflag to stack
|
||||
"popl %%eax \n\t" // get Eflag from stack
|
||||
"pushl %%ecx \n\t" // save original Eflag to stack
|
||||
"popfl \n\t" // restore original Eflag
|
||||
#endif
|
||||
"xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag
|
||||
"jz 0f \n\t" // if same, CPUID instr. is not supported
|
||||
|
||||
"xorl %%eax, %%eax \n\t" // set eax to zero
|
||||
// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode)
|
||||
"cpuid \n\t" // get the CPU identification info
|
||||
"cmpl $1, %%eax \n\t" // make sure eax return non-zero value
|
||||
"jl 0f \n\t" // if eax is zero, MMX is not supported
|
||||
|
||||
"xorl %%eax, %%eax \n\t" // set eax to zero and...
|
||||
"incl %%eax \n\t" // ...increment eax to 1. This pair is
|
||||
// faster than the instruction "mov eax, 1"
|
||||
"cpuid \n\t" // get the CPU identification info again
|
||||
"andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23)
|
||||
"cmpl $0, %%edx \n\t" // 0 = MMX not supported
|
||||
"jz 0f \n\t" // non-zero = yes, MMX IS supported
|
||||
|
||||
"movl $1, %%eax \n\t" // set return value to 1
|
||||
"jmp 1f \n\t" // DONE: have MMX support
|
||||
|
||||
"0: \n\t" // .NOT_SUPPORTED: target label for jump instructions
|
||||
"movl $0, %%eax \n\t" // set return value to 0
|
||||
"1: \n\t" // .RETURN: target label for jump instructions
|
||||
#if defined(__x86_64__)
|
||||
"popq %%rdx \n\t" // restore rdx
|
||||
"popq %%rcx \n\t" // restore rcx
|
||||
"popq %%rbx \n\t" // restore rbx
|
||||
#else
|
||||
"popl %%edx \n\t" // restore edx
|
||||
"popl %%ecx \n\t" // restore ecx
|
||||
"popl %%ebx \n\t" // restore ebx
|
||||
#endif
|
||||
|
||||
// "ret \n\t" // DONE: no MMX support
|
||||
// (fall through to standard C "ret")
|
||||
|
||||
: "=a" (result) // output list
|
||||
|
||||
: // any variables used on input (none)
|
||||
|
||||
// no clobber list
|
||||
// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually
|
||||
// , "memory" // if write to a variable gcc thought was in a reg
|
||||
// , "cc" // "condition codes" (flag bits)
|
||||
);
|
||||
_mmx_supported = result;
|
||||
#else
|
||||
_mmx_supported = 0;
|
||||
#endif /* PNG_MMX_CODE_SUPPORTED */
|
||||
|
||||
return _mmx_supported;
|
||||
}
|
||||
#endif
|
901
third_party/libpng/pngget.c
vendored
Normal file
901
third_party/libpng/pngget.c
vendored
Normal file
@ -0,0 +1,901 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.2.15 January 5, 2007
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->valid & flag);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->rowbytes);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
png_bytepp PNGAPI
|
||||
png_get_rows(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->row_pointers);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* easy access to info, added in libpng-0.99 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->width;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->height;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->bit_depth;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->color_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->filter_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->interlace_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->compression_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->y_pixels_per_unit);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
|
||||
if (info_ptr->x_pixels_per_unit == 0)
|
||||
return ((float)0.0);
|
||||
else
|
||||
return ((float)((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit));
|
||||
}
|
||||
#else
|
||||
return (0.0);
|
||||
#endif
|
||||
return ((float)0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
#else
|
||||
return (0);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.0254 +.5));
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.0254 +.5));
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.0254 +.5));
|
||||
}
|
||||
|
||||
float PNGAPI
|
||||
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
|
||||
*.00003937);
|
||||
}
|
||||
|
||||
float PNGAPI
|
||||
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
|
||||
*.00003937);
|
||||
}
|
||||
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
{
|
||||
*res_x = info_ptr->x_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (res_y != NULL)
|
||||
{
|
||||
*res_y = info_ptr->y_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (unit_type != NULL)
|
||||
{
|
||||
*unit_type = (int)info_ptr->phys_unit_type;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
if(*unit_type == 1)
|
||||
{
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
#endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->channels);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_bytep PNGAPI
|
||||
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->signature);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||
&& background != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "bKGD");
|
||||
*background = &(info_ptr->background);
|
||||
return (PNG_INFO_bKGD);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "cHRM");
|
||||
if (white_x != NULL)
|
||||
*white_x = (double)info_ptr->x_white;
|
||||
if (white_y != NULL)
|
||||
*white_y = (double)info_ptr->y_white;
|
||||
if (red_x != NULL)
|
||||
*red_x = (double)info_ptr->x_red;
|
||||
if (red_y != NULL)
|
||||
*red_y = (double)info_ptr->y_red;
|
||||
if (green_x != NULL)
|
||||
*green_x = (double)info_ptr->x_green;
|
||||
if (green_y != NULL)
|
||||
*green_y = (double)info_ptr->y_green;
|
||||
if (blue_x != NULL)
|
||||
*blue_x = (double)info_ptr->x_blue;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = (double)info_ptr->y_blue;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
|
||||
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "cHRM");
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->int_x_white;
|
||||
if (white_y != NULL)
|
||||
*white_y = info_ptr->int_y_white;
|
||||
if (red_x != NULL)
|
||||
*red_x = info_ptr->int_x_red;
|
||||
if (red_y != NULL)
|
||||
*red_y = info_ptr->int_y_red;
|
||||
if (green_x != NULL)
|
||||
*green_x = info_ptr->int_x_green;
|
||||
if (green_y != NULL)
|
||||
*green_y = info_ptr->int_y_green;
|
||||
if (blue_x != NULL)
|
||||
*blue_x = info_ptr->int_x_blue;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = info_ptr->int_y_blue;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& file_gamma != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "gAMA");
|
||||
*file_gamma = (double)info_ptr->gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point *int_file_gamma)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& int_file_gamma != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "gAMA");
|
||||
*int_file_gamma = info_ptr->int_gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sRGB_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
&& file_srgb_intent != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sRGB");
|
||||
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_charpp profile, png_uint_32 *proflen)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||
&& name != NULL && profile != NULL && proflen != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "iCCP");
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
/* compression_type is a dummy so the API won't have to change
|
||||
if we introduce multiple compression types later. */
|
||||
*proflen = (int)info_ptr->iccp_proflen;
|
||||
*compression_type = (int)info_ptr->iccp_compression;
|
||||
return (PNG_INFO_iCCP);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
{
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||
&& hist != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "hIST");
|
||||
*hist = info_ptr->hist;
|
||||
return (PNG_INFO_hIST);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
||||
int *color_type, int *interlace_type, int *compression_type,
|
||||
int *filter_type)
|
||||
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
|
||||
bit_depth != NULL && color_type != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "IHDR");
|
||||
*width = info_ptr->width;
|
||||
*height = info_ptr->height;
|
||||
*bit_depth = info_ptr->bit_depth;
|
||||
if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
|
||||
png_error(png_ptr, "Invalid bit depth");
|
||||
*color_type = info_ptr->color_type;
|
||||
if (info_ptr->color_type > 6)
|
||||
png_error(png_ptr, "Invalid color type");
|
||||
if (compression_type != NULL)
|
||||
*compression_type = info_ptr->compression_type;
|
||||
if (filter_type != NULL)
|
||||
*filter_type = info_ptr->filter_type;
|
||||
if (interlace_type != NULL)
|
||||
*interlace_type = info_ptr->interlace_type;
|
||||
|
||||
/* check for potential overflow of rowbytes */
|
||||
if (*width == 0 || *width > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "Invalid image width");
|
||||
if (*height == 0 || *height > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "Invalid image height");
|
||||
if (info_ptr->width > (PNG_UINT_32_MAX
|
||||
>> 3) /* 8-byte RGBA pixels */
|
||||
- 64 /* bigrowbuf hack */
|
||||
- 1 /* filter byte */
|
||||
- 7*8 /* rounding of width to multiple of 8 pixels */
|
||||
- 8) /* extra max_pixel_depth pad */
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Width too large for libpng to process image data.");
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(PNG_oFFs_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "oFFs");
|
||||
*offset_x = info_ptr->x_offset;
|
||||
*offset_y = info_ptr->y_offset;
|
||||
*unit_type = (int)info_ptr->offset_unit_type;
|
||||
return (PNG_INFO_oFFs);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
||||
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
nparams != NULL && units != NULL && params != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pCAL");
|
||||
*purpose = info_ptr->pcal_purpose;
|
||||
*X0 = info_ptr->pcal_X0;
|
||||
*X1 = info_ptr->pcal_X1;
|
||||
*type = (int)info_ptr->pcal_type;
|
||||
*nparams = (int)info_ptr->pcal_nparams;
|
||||
*units = info_ptr->pcal_units;
|
||||
*params = info_ptr->pcal_params;
|
||||
return (PNG_INFO_pCAL);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
int *unit, double *width, double *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_pixel_width;
|
||||
*height = info_ptr->scal_pixel_height;
|
||||
return (PNG_INFO_sCAL);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_s_width;
|
||||
*height = info_ptr->scal_s_height;
|
||||
return (PNG_INFO_sCAL);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_pHYs_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
{
|
||||
*res_x = info_ptr->x_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (res_y != NULL)
|
||||
{
|
||||
*res_y = info_ptr->y_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (unit_type != NULL)
|
||||
{
|
||||
*unit_type = (int)info_ptr->phys_unit_type;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
int *num_palette)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
||||
&& palette != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "PLTE");
|
||||
*palette = info_ptr->palette;
|
||||
*num_palette = info_ptr->num_palette;
|
||||
png_debug1(3, "num_palette = %d\n", *num_palette);
|
||||
return (PNG_INFO_PLTE);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(PNG_sBIT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
||||
&& sig_bit != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sBIT");
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
return (PNG_INFO_sBIT);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
int *num_text)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n",
|
||||
(png_ptr->chunk_name[0] == '\0' ? "text"
|
||||
: (png_const_charp)png_ptr->chunk_name));
|
||||
if (text_ptr != NULL)
|
||||
*text_ptr = info_ptr->text;
|
||||
if (num_text != NULL)
|
||||
*num_text = info_ptr->num_text;
|
||||
return ((png_uint_32)info_ptr->num_text);
|
||||
}
|
||||
if (num_text != NULL)
|
||||
*num_text = 0;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tIME_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
||||
&& mod_time != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tIME");
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
return (PNG_INFO_tIME);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tRNS");
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (trans != NULL)
|
||||
{
|
||||
*trans = info_ptr->trans;
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
if (trans_values != NULL)
|
||||
*trans_values = &(info_ptr->trans_values);
|
||||
}
|
||||
else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
|
||||
{
|
||||
if (trans_values != NULL)
|
||||
{
|
||||
*trans_values = &(info_ptr->trans_values);
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
if(trans != NULL)
|
||||
*trans = NULL;
|
||||
}
|
||||
if(num_trans != NULL)
|
||||
{
|
||||
*num_trans = info_ptr->num_trans;
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||
{
|
||||
*unknowns = info_ptr->unknown_chunks;
|
||||
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_structp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_USER_CHUNKS_SUPPORTED)
|
||||
png_voidp PNGAPI
|
||||
png_get_user_chunk_ptr(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_chunk_ptr : NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_compression_buffer_size(png_structp png_ptr)
|
||||
{
|
||||
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
#ifndef PNG_1_0_X
|
||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_asm_flags (png_structp png_ptr)
|
||||
{
|
||||
/* obsolete, to be removed from libpng-1.4.0 */
|
||||
return (png_ptr? 0L: 0L);
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_asm_flagmask (int flag_select)
|
||||
{
|
||||
/* obsolete, to be removed from libpng-1.4.0 */
|
||||
flag_select=flag_select;
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_mmx_flagmask (int flag_select, int *compilerID)
|
||||
{
|
||||
/* obsolete, to be removed from libpng-1.4.0 */
|
||||
flag_select=flag_select;
|
||||
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
png_byte PNGAPI
|
||||
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
|
||||
{
|
||||
/* obsolete, to be removed from libpng-1.4.0 */
|
||||
return (png_ptr? 0: 0);
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
|
||||
{
|
||||
/* obsolete, to be removed from libpng-1.4.0 */
|
||||
return (png_ptr? 0L: 0L);
|
||||
}
|
||||
#endif /* ?PNG_1_0_X */
|
||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* these functions were added to libpng 1.2.6 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_width_max (png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_width_max : 0);
|
||||
}
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_height_max (png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_height_max : 0);
|
||||
}
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
608
third_party/libpng/pngmem.c
vendored
Normal file
608
third_party/libpng/pngmem.c
vendored
Normal file
@ -0,0 +1,608 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.2.13 November 13, 2006
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users who
|
||||
* need special memory handling are expected to supply replacement
|
||||
* functions for png_malloc() and png_free(), and to use
|
||||
* png_create_read_struct_2() and png_create_write_struct_2() to
|
||||
* identify the replacement functions.
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* if you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL));
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
else
|
||||
return (png_get_copyright(NULL));
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
|
||||
}
|
||||
else
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
#endif
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
farfree (struct_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
*
|
||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||
* It gives you a segment with an offset of 8 (perhaps to store its
|
||||
* memory stuff). zlib doesn't like this at all, so we have to
|
||||
* detect and deal with it. This code should not be needed in
|
||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
||||
* been updated by Alexander Lehmann for version 0.89 to waste less
|
||||
* memory.
|
||||
*
|
||||
* Note that we can't use png_size_t for the "size" declaration,
|
||||
* since on some systems a png_size_t is a 16-bit quantity, and as a
|
||||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory!");
|
||||
return (ret);
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
||||
ret = NULL;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
else if (size == (png_uint_32)65536L)
|
||||
{
|
||||
if (png_ptr->offset_table == NULL)
|
||||
{
|
||||
/* try to see if we need to do any of this fancy stuff */
|
||||
ret = farmalloc(size);
|
||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
||||
{
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i;
|
||||
png_byte huge * hptr;
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if(png_ptr->zlib_window_bits > 14)
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
else
|
||||
num_blocks = 1;
|
||||
if (png_ptr->zlib_mem_level >= 7)
|
||||
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (table == NULL)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
|
||||
else
|
||||
png_warning(png_ptr, "Out Of Memory.");
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
||||
png_sizeof (png_bytep));
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */
|
||||
else
|
||||
png_warning(png_ptr, "Out Of memory.");
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
if ((png_size_t)hptr & 0xf)
|
||||
{
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
||||
}
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
|
||||
}
|
||||
|
||||
png_ptr->offset_table_number = num_blocks;
|
||||
png_ptr->offset_table_count = 0;
|
||||
png_ptr->offset_table_count_free = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */
|
||||
else
|
||||
png_warning(png_ptr, "Out of Memory.");
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
|
||||
else
|
||||
png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */
|
||||
}
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* free a pointer allocated by png_malloc(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
else png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
|
||||
if (png_ptr->offset_table != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
||||
{
|
||||
if (ptr == png_ptr->offset_table_ptr[i])
|
||||
{
|
||||
ptr = NULL;
|
||||
png_ptr->offset_table_count_free++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
||||
{
|
||||
farfree(png_ptr->offset_table);
|
||||
farfree(png_ptr->offset_table_ptr);
|
||||
png_ptr->offset_table = NULL;
|
||||
png_ptr->offset_table_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
farfree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL));
|
||||
}
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
else
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
return (struct_ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
struct_ptr = (png_voidp)halloc(size,1);
|
||||
# else
|
||||
struct_ptr = (png_voidp)malloc(size);
|
||||
# endif
|
||||
#endif
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
|
||||
}
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void /* PRIVATE */
|
||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
# else
|
||||
free(struct_ptr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
64K. However, zlib may allocate more then 64K if you don't tell
|
||||
it not to. See zconf.h and png.h for more information. zlib does
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that. */
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
if(png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory!");
|
||||
return (ret);
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
else
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check for overflow */
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = halloc(size, 1);
|
||||
# else
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = malloc((size_t)size);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
without taking any action. */
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
else png_free_default(png_ptr, ptr);
|
||||
}
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
# else
|
||||
free(ptr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
#if defined(PNG_1_0_X)
|
||||
# define png_malloc_warn png_malloc
|
||||
#else
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will set up png_malloc() to issue a png_warning and return NULL
|
||||
* instead of issuing a png_error, if it fails to allocate the requested
|
||||
* memory.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ptr;
|
||||
png_uint_32 save_flags;
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
|
||||
save_flags=png_ptr->flags;
|
||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||
png_ptr->flags=save_flags;
|
||||
return(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_size_t size;
|
||||
|
||||
size = (png_size_t)length;
|
||||
if ((png_uint_32)size != length)
|
||||
png_error(png_ptr,"Overflow in png_memcpy_check.");
|
||||
|
||||
return(png_memcpy (s1, s2, size));
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_size_t size;
|
||||
|
||||
size = (png_size_t)length;
|
||||
if ((png_uint_32)size != length)
|
||||
png_error(png_ptr,"Overflow in png_memset_check.");
|
||||
|
||||
return (png_memset (s1, value, size));
|
||||
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* This function is called when the application wants to use another method
|
||||
* of allocating and freeing memory.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
if(png_ptr != NULL) {
|
||||
png_ptr->mem_ptr = mem_ptr;
|
||||
png_ptr->malloc_fn = malloc_fn;
|
||||
png_ptr->free_fn = free_fn;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns a pointer to the mem_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
* pointer before png_write_destroy and png_read_destroy are called.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_structp png_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
1580
third_party/libpng/pngpread.c
vendored
Normal file
1580
third_party/libpng/pngpread.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1472
third_party/libpng/pngread.c
vendored
Normal file
1472
third_party/libpng/pngread.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user