Initial checkin of Pika from heckimp
This commit is contained in:
1023
plug-ins/file-bmp/bmp-load.c
Normal file
1023
plug-ins/file-bmp/bmp-load.c
Normal file
File diff suppressed because it is too large
Load Diff
27
plug-ins/file-bmp/bmp-load.h
Normal file
27
plug-ins/file-bmp/bmp-load.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* PIKA - Photo and Image Kooker Application
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BMP_LOAD_H__
|
||||
#define __BMP_LOAD_H__
|
||||
|
||||
|
||||
PikaImage * load_image (GFile *file,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __BMP_LOAD_H__ */
|
1078
plug-ins/file-bmp/bmp-save.c
Normal file
1078
plug-ins/file-bmp/bmp-save.c
Normal file
File diff suppressed because it is too large
Load Diff
32
plug-ins/file-bmp/bmp-save.h
Normal file
32
plug-ins/file-bmp/bmp-save.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* PIKA - Photo and Image Kooker Application
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BMP_SAVE_H__
|
||||
#define __BMP_SAVE_H__
|
||||
|
||||
|
||||
PikaPDBStatusType save_image (GFile *file,
|
||||
PikaImage *image,
|
||||
PikaDrawable *drawable,
|
||||
PikaRunMode run_mode,
|
||||
PikaProcedure *procedure,
|
||||
GObject *config,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __BMP_SAVE_H__ */
|
317
plug-ins/file-bmp/bmp.c
Normal file
317
plug-ins/file-bmp/bmp.c
Normal file
@ -0,0 +1,317 @@
|
||||
/* bmp.c */
|
||||
/* Version 0.52 */
|
||||
/* This is a File input and output filter for the */
|
||||
/* Pika. It loads and saves images in windows(TM) */
|
||||
/* bitmap format. */
|
||||
/* Some Parts that deal with the interaction with */
|
||||
/* PIKA are taken from the GIF plugin by */
|
||||
/* Peter Mattis & Spencer Kimball and from the */
|
||||
/* PCX plugin by Francisco Bustamante. */
|
||||
/* */
|
||||
/* Alexander.Schulz@stud.uni-karlsruhe.de */
|
||||
|
||||
/* Changes: 28.11.1997 Noninteractive operation */
|
||||
/* 16.03.1998 Endian-independent!! */
|
||||
/* 21.03.1998 Little Bug-fix */
|
||||
/* 06.04.1998 Bugfix in Padding */
|
||||
/* 11.04.1998 Arch. cleanup (-Wall) */
|
||||
/* Parses gtkrc */
|
||||
/* 14.04.1998 Another Bug in Padding */
|
||||
/* 28.04.1998 RLE-Encoding rewritten */
|
||||
/* 29.10.1998 Changes by Tor Lillqvist */
|
||||
/* <tml@iki.fi> to support */
|
||||
/* 16 and 32 bit images */
|
||||
/* 28.11.1998 Bug in RLE-read-padding */
|
||||
/* fixed. */
|
||||
/* 19.12.1999 Resolution support added */
|
||||
/* 06.05.2000 Overhaul for 16&24-bit */
|
||||
/* plus better OS/2 code */
|
||||
/* by njl195@zepler.org.uk */
|
||||
/* 29.06.2006 Full support for 16/32 */
|
||||
/* bits bitmaps and support */
|
||||
/* for alpha channel */
|
||||
/* by p.filiciak@zax.pl */
|
||||
|
||||
/*
|
||||
* PIKA - Photo and Image Kooker Application
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libpika/pika.h>
|
||||
#include <libpika/pikaui.h>
|
||||
|
||||
#include "bmp.h"
|
||||
#include "bmp-load.h"
|
||||
#include "bmp-save.h"
|
||||
|
||||
#include "libpika/stdplugins-intl.h"
|
||||
|
||||
|
||||
typedef struct _Bmp Bmp;
|
||||
typedef struct _BmpClass BmpClass;
|
||||
|
||||
struct _Bmp
|
||||
{
|
||||
PikaPlugIn parent_instance;
|
||||
};
|
||||
|
||||
struct _BmpClass
|
||||
{
|
||||
PikaPlugInClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
#define BMP_TYPE (bmp_get_type ())
|
||||
#define BMP (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BMP_TYPE, Bmp))
|
||||
|
||||
GType bmp_get_type (void) G_GNUC_CONST;
|
||||
|
||||
static GList * bmp_query_procedures (PikaPlugIn *plug_in);
|
||||
static PikaProcedure * bmp_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
static PikaValueArray * bmp_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
static PikaValueArray * bmp_save (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
PikaImage *image,
|
||||
gint n_drawables,
|
||||
PikaDrawable **drawables,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
|
||||
|
||||
|
||||
G_DEFINE_TYPE (Bmp, bmp, PIKA_TYPE_PLUG_IN)
|
||||
|
||||
PIKA_MAIN (BMP_TYPE)
|
||||
DEFINE_STD_SET_I18N
|
||||
|
||||
|
||||
static void
|
||||
bmp_class_init (BmpClass *klass)
|
||||
{
|
||||
PikaPlugInClass *plug_in_class = PIKA_PLUG_IN_CLASS (klass);
|
||||
|
||||
plug_in_class->query_procedures = bmp_query_procedures;
|
||||
plug_in_class->create_procedure = bmp_create_procedure;
|
||||
plug_in_class->set_i18n = STD_SET_I18N;
|
||||
}
|
||||
|
||||
static void
|
||||
bmp_init (Bmp *bmp)
|
||||
{
|
||||
}
|
||||
|
||||
static GList *
|
||||
bmp_query_procedures (PikaPlugIn *plug_in)
|
||||
{
|
||||
GList *list = NULL;
|
||||
|
||||
list = g_list_append (list, g_strdup (LOAD_PROC));
|
||||
list = g_list_append (list, g_strdup (SAVE_PROC));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static PikaProcedure *
|
||||
bmp_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
PikaProcedure *procedure = NULL;
|
||||
|
||||
if (! strcmp (name, LOAD_PROC))
|
||||
{
|
||||
procedure = pika_load_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
bmp_load, NULL, NULL);
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("Windows BMP image"));
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
_("Loads files of Windows BMP file format"),
|
||||
_("Loads files of Windows BMP file format"),
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Alexander Schulz",
|
||||
"Alexander Schulz",
|
||||
"1997");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
"image/bmp");
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
"bmp");
|
||||
pika_file_procedure_set_magics (PIKA_FILE_PROCEDURE (procedure),
|
||||
"0,string,BM");
|
||||
}
|
||||
else if (! strcmp (name, SAVE_PROC))
|
||||
{
|
||||
procedure = pika_save_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
bmp_save, NULL, NULL);
|
||||
|
||||
pika_procedure_set_image_types (procedure, "INDEXED, GRAY, RGB*");
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("Windows BMP image"));
|
||||
pika_file_procedure_set_format_name (PIKA_FILE_PROCEDURE (procedure),
|
||||
_("BMP"));
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
_("Saves files in Windows BMP file format"),
|
||||
_("Saves files in Windows BMP file format"),
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Alexander Schulz",
|
||||
"Alexander Schulz",
|
||||
"1997");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
"image/bmp");
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
"bmp");
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "use-rle",
|
||||
_("Ru_n-Length Encoded"),
|
||||
_("Use run-length-encoding compression "
|
||||
"(only valid for 4 and 8-bit indexed images)"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "write-color-space",
|
||||
_("_Write color space information"),
|
||||
_("Whether or not to write BITMAPV5HEADER "
|
||||
"color space data"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "rgb-format",
|
||||
_("R_GB format"),
|
||||
_("Export format for RGB images "
|
||||
"(0=RGB_565, 1=RGBA_5551, 2=RGB_555, 3=RGB_888, "
|
||||
"4=RGBA_8888, 5=RGBX_8888)"),
|
||||
0, 5, 3,
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
bmp_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaValueArray *return_vals;
|
||||
PikaImage *image;
|
||||
GError *error = NULL;
|
||||
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
image = load_image (file, &error);
|
||||
|
||||
if (! image)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
|
||||
return_vals = pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
PIKA_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
bmp_save (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
PikaImage *image,
|
||||
gint n_drawables,
|
||||
PikaDrawable **drawables,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaProcedureConfig *config;
|
||||
PikaPDBStatusType status = PIKA_PDB_SUCCESS;
|
||||
PikaExportReturn export = PIKA_EXPORT_CANCEL;
|
||||
GError *error = NULL;
|
||||
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
config = pika_procedure_create_config (procedure);
|
||||
pika_procedure_config_begin_run (config, image, run_mode, args);
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case PIKA_RUN_INTERACTIVE:
|
||||
case PIKA_RUN_WITH_LAST_VALS:
|
||||
pika_ui_init (PLUG_IN_BINARY);
|
||||
|
||||
export = pika_export_image (&image, &n_drawables, &drawables, "BMP",
|
||||
PIKA_EXPORT_CAN_HANDLE_RGB |
|
||||
PIKA_EXPORT_CAN_HANDLE_GRAY |
|
||||
PIKA_EXPORT_CAN_HANDLE_ALPHA |
|
||||
PIKA_EXPORT_CAN_HANDLE_INDEXED);
|
||||
|
||||
if (export == PIKA_EXPORT_CANCEL)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_CANCEL,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (n_drawables != 1)
|
||||
{
|
||||
g_set_error (&error, G_FILE_ERROR, 0,
|
||||
_("BMP format does not support multiple layers."));
|
||||
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_CALLING_ERROR,
|
||||
error);
|
||||
}
|
||||
|
||||
status = save_image (file, image, drawables[0], run_mode,
|
||||
procedure, G_OBJECT (config),
|
||||
&error);
|
||||
|
||||
pika_procedure_config_end_run (config, status);
|
||||
g_object_unref (config);
|
||||
|
||||
if (export == PIKA_EXPORT_EXPORT)
|
||||
{
|
||||
pika_image_delete (image);
|
||||
g_free (drawables);
|
||||
}
|
||||
|
||||
return pika_procedure_new_return_values (procedure, status, error);
|
||||
}
|
70
plug-ins/file-bmp/bmp.h
Normal file
70
plug-ins/file-bmp/bmp.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* PIKA - Photo and Image Kooker Application
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __BMP_H__
|
||||
#define __BMP_H__
|
||||
|
||||
|
||||
#define LOAD_PROC "file-bmp-load"
|
||||
#define SAVE_PROC "file-bmp-save"
|
||||
#define PLUG_IN_BINARY "file-bmp"
|
||||
#define PLUG_IN_ROLE "pika-file-bmp"
|
||||
|
||||
#define MAXCOLORS 256
|
||||
|
||||
#define BitSet(byte, bit) (((byte) & (bit)) == (bit))
|
||||
|
||||
#define ReadOK(file,buffer,len) (fread(buffer, len, 1, file) != 0)
|
||||
#define Write(file,buffer,len) fwrite(buffer, len, 1, file)
|
||||
#define WriteOK(file,buffer,len) (Write(buffer, len, file) != 0)
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar zzMagic[2]; /* 00 "BM" */
|
||||
guint32 bfSize; /* 02 */
|
||||
guint16 zzHotX; /* 06 */
|
||||
guint16 zzHotY; /* 08 */
|
||||
guint32 bfOffs; /* 0A */
|
||||
guint32 biSize; /* 0E */
|
||||
} BitmapFileHead;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint32 biWidth; /* 12 */
|
||||
gint32 biHeight; /* 16 */
|
||||
guint16 biPlanes; /* 1A */
|
||||
guint16 biBitCnt; /* 1C */
|
||||
guint32 biCompr; /* 1E */
|
||||
guint32 biSizeIm; /* 22 */
|
||||
guint32 biXPels; /* 26 */
|
||||
guint32 biYPels; /* 2A */
|
||||
guint32 biClrUsed; /* 2E */
|
||||
guint32 biClrImp; /* 32 */
|
||||
guint32 masks[4]; /* 36 */
|
||||
} BitmapHead;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint32 mask;
|
||||
guint32 shiftin;
|
||||
gfloat max_value;
|
||||
} BitmapChannel;
|
||||
|
||||
|
||||
#endif /* __BMP_H__ */
|
28
plug-ins/file-bmp/meson.build
Normal file
28
plug-ins/file-bmp/meson.build
Normal file
@ -0,0 +1,28 @@
|
||||
plugin_name = 'file-bmp'
|
||||
|
||||
plugin_sources = [
|
||||
'bmp-load.c',
|
||||
'bmp-save.c',
|
||||
'bmp.c',
|
||||
]
|
||||
|
||||
if platform_windows
|
||||
plugin_sources += windows.compile_resources(
|
||||
pika_plugins_rc,
|
||||
args: [
|
||||
'--define', 'ORIGINALFILENAME_STR="@0@"'.format(plugin_name+'.exe'),
|
||||
'--define', 'INTERNALNAME_STR="@0@"' .format(plugin_name),
|
||||
'--define', 'TOP_SRCDIR="@0@"' .format(meson.project_source_root()),
|
||||
],
|
||||
include_directories: [
|
||||
rootInclude, appInclude,
|
||||
],
|
||||
)
|
||||
endif
|
||||
|
||||
executable(plugin_name,
|
||||
plugin_sources,
|
||||
dependencies: libpikaui_dep,
|
||||
install: true,
|
||||
install_dir: pikaplugindir / 'plug-ins' / plugin_name,
|
||||
)
|
Reference in New Issue
Block a user