summaryrefslogtreecommitdiffstats
path: root/plug-ins/file-psd/psd-util.h
blob: efa8aa7beae9ec81716a4649bae5b075996c9faf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * GIMP PSD Plug-in
 * Copyright 2007 by John Marshall
 *
 * 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 __PSD_UTIL_H__
#define __PSD_UTIL_H__

/*
 *  Set file read error
 */
void                    psd_set_error          (gboolean             file_eof,
                                                gint                 err_no,
                                                GError             **error);

/*
 * Reads a pascal string from the file padded to a multiple of mod_len
 * and returns a utf-8 string.
 */
gchar                 * fread_pascal_string    (gint32              *bytes_read,
                                                gint32              *bytes_written,
                                                guint16              mod_len,
                                                FILE                *f,
                                                GError             **error);

/*
 *  Converts utf-8 string to current locale and writes as pascal
 *  string with padding to a multiple of mod_len.
 */
gint32                  fwrite_pascal_string   (const gchar         *src,
                                                guint16              mod_len,
                                                FILE                *f,
                                                GError             **error);

/*
 * Reads a utf-16 string from the file padded to a multiple of mod_len
 * and returns a utf-8 string.
 */
gchar                 * fread_unicode_string   (gint32              *bytes_read,
                                                gint32              *bytes_written,
                                                guint16              mod_len,
                                                FILE                *f,
                                                GError             **error);

/*
 *  Converts utf-8 string to utf-16 and writes 4 byte length
 *  then string padding to multiple of mod_len.
 */
gint32                  fwrite_unicode_string  (const gchar         *src,
                                                guint16              mod_len,
                                                FILE                *f,
                                                GError             **error);

gint                    decode_packbits        (const gchar         *src,
                                                gchar               *dst,
                                                guint16              packed_len,
                                                guint32              unpacked_len);

gchar                 * encode_packbits        (const gchar         *src,
                                                guint32              unpacked_len,
                                                guint16             *packed_len);

void                    psd_to_gimp_blend_mode (PSDlayer             *psd_layer,
                                                LayerModeInfo        *mode_info);

const gchar *           gimp_to_psd_blend_mode (const LayerModeInfo  *mode_info);

GimpColorTag            psd_to_gimp_layer_color_tag (guint16          layer_color_tag);

guint16                 gimp_to_psd_layer_color_tag (GimpColorTag     layer_color_tag);

#endif /* __PSD_UTIL_H__ */