Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/include/mupdf/fitz/bitmap.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 // Copyright (C) 2004-2025 Artifex Software, Inc. | |
| 2 // | |
| 3 // This file is part of MuPDF. | |
| 4 // | |
| 5 // MuPDF is free software: you can redistribute it and/or modify it under the | |
| 6 // terms of the GNU Affero General Public License as published by the Free | |
| 7 // Software Foundation, either version 3 of the License, or (at your option) | |
| 8 // any later version. | |
| 9 // | |
| 10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | |
| 13 // details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU Affero General Public License | |
| 16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html> | |
| 17 // | |
| 18 // Alternative licensing terms are available from the licensor. | |
| 19 // For commercial licensing, see <https://www.artifex.com/> or contact | |
| 20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, | |
| 21 // CA 94129, USA, for further information. | |
| 22 | |
| 23 #ifndef MUPDF_FITZ_BITMAP_H | |
| 24 #define MUPDF_FITZ_BITMAP_H | |
| 25 | |
| 26 #include "mupdf/fitz/system.h" | |
| 27 #include "mupdf/fitz/context.h" | |
| 28 #include "mupdf/fitz/pixmap.h" | |
| 29 | |
| 30 /** | |
| 31 Bitmaps have 1 bit per component. Only used for creating | |
| 32 halftoned versions of contone buffers, and saving out. Samples | |
| 33 are stored msb first, akin to pbms. | |
| 34 | |
| 35 The internals of this struct are considered implementation | |
| 36 details and subject to change. Where possible, accessor | |
| 37 functions should be used in preference. | |
| 38 */ | |
| 39 typedef struct | |
| 40 { | |
| 41 int refs; | |
| 42 int w, h, stride, n; | |
| 43 int xres, yres; | |
| 44 unsigned char *samples; | |
| 45 } fz_bitmap; | |
| 46 | |
| 47 /** | |
| 48 Take an additional reference to the bitmap. The same pointer | |
| 49 is returned. | |
| 50 | |
| 51 Never throws exceptions. | |
| 52 */ | |
| 53 fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit); | |
| 54 | |
| 55 /** | |
| 56 Drop a reference to the bitmap. When the reference count reaches | |
| 57 zero, the bitmap will be destroyed. | |
| 58 | |
| 59 Never throws exceptions. | |
| 60 */ | |
| 61 void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit); | |
| 62 | |
| 63 /** | |
| 64 Invert bitmap. | |
| 65 | |
| 66 Never throws exceptions. | |
| 67 */ | |
| 68 void fz_invert_bitmap(fz_context *ctx, fz_bitmap *bmp); | |
| 69 | |
| 70 /** | |
| 71 A halftone is a set of threshold tiles, one per component. Each | |
| 72 threshold tile is a pixmap, possibly of varying sizes and | |
| 73 phases. Currently, we only provide one 'default' halftone tile | |
| 74 for operating on 1 component plus alpha pixmaps (where the alpha | |
| 75 is ignored). This is signified by a fz_halftone pointer to NULL. | |
| 76 */ | |
| 77 typedef struct fz_halftone fz_halftone; | |
| 78 | |
| 79 /** | |
| 80 Make a bitmap from a pixmap and a halftone. | |
| 81 | |
| 82 pix: The pixmap to generate from. Currently must be a single | |
| 83 color component with no alpha. | |
| 84 | |
| 85 ht: The halftone to use. NULL implies the default halftone. | |
| 86 | |
| 87 Returns the resultant bitmap. Throws exceptions in the case of | |
| 88 failure to allocate. | |
| 89 */ | |
| 90 fz_bitmap *fz_new_bitmap_from_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht); | |
| 91 | |
| 92 /** | |
| 93 Make a bitmap from a pixmap and a halftone. | |
| 94 | |
| 95 img: The image to generate from. Currently must be a single | |
| 96 color component with no alpha. | |
| 97 | |
| 98 ht: The halftone to use. NULL implies the default halftone. | |
| 99 | |
| 100 Returns the resultant bitmap. Throws exceptions in the case of | |
| 101 failure to allocate. | |
| 102 */ | |
| 103 fz_bitmap *fz_new_bitmap_from_image(fz_context *ctx, fz_image *img, fz_halftone *ht); | |
| 104 | |
| 105 /** | |
| 106 Make a bitmap from a pixmap and a | |
| 107 halftone, allowing for the position of the pixmap within an | |
| 108 overall banded rendering. | |
| 109 | |
| 110 pix: The pixmap to generate from. Currently must be a single | |
| 111 color component with no alpha. | |
| 112 | |
| 113 ht: The halftone to use. NULL implies the default halftone. | |
| 114 | |
| 115 band_start: Vertical offset within the overall banded rendering | |
| 116 (in pixels) | |
| 117 | |
| 118 Returns the resultant bitmap. Throws exceptions in the case of | |
| 119 failure to allocate. | |
| 120 */ | |
| 121 fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band_start); | |
| 122 | |
| 123 /** | |
| 124 Create a new bitmap. | |
| 125 | |
| 126 w, h: Width and Height for the bitmap | |
| 127 | |
| 128 n: Number of color components (assumed to be a divisor of 8) | |
| 129 | |
| 130 xres, yres: X and Y resolutions (in pixels per inch). | |
| 131 | |
| 132 Returns pointer to created bitmap structure. The bitmap | |
| 133 data is uninitialised. | |
| 134 */ | |
| 135 fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n, int xres, int yres); | |
| 136 | |
| 137 /** | |
| 138 Retrieve details of a given bitmap. | |
| 139 | |
| 140 bitmap: The bitmap to query. | |
| 141 | |
| 142 w: Pointer to storage to retrieve width (or NULL). | |
| 143 | |
| 144 h: Pointer to storage to retrieve height (or NULL). | |
| 145 | |
| 146 n: Pointer to storage to retrieve number of color components (or | |
| 147 NULL). | |
| 148 | |
| 149 stride: Pointer to storage to retrieve bitmap stride (or NULL). | |
| 150 */ | |
| 151 void fz_bitmap_details(fz_bitmap *bitmap, int *w, int *h, int *n, int *stride); | |
| 152 | |
| 153 /** | |
| 154 Set the entire bitmap to 0. | |
| 155 | |
| 156 Never throws exceptions. | |
| 157 */ | |
| 158 void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit); | |
| 159 | |
| 160 /** | |
| 161 Create a 'default' halftone structure | |
| 162 for the given number of components. | |
| 163 | |
| 164 num_comps: The number of components to use. | |
| 165 | |
| 166 Returns a simple default halftone. The default halftone uses | |
| 167 the same halftone tile for each plane, which may not be ideal | |
| 168 for all purposes. | |
| 169 */ | |
| 170 fz_halftone *fz_default_halftone(fz_context *ctx, int num_comps); | |
| 171 | |
| 172 /** | |
| 173 Take an additional reference to the halftone. The same pointer | |
| 174 is returned. | |
| 175 | |
| 176 Never throws exceptions. | |
| 177 */ | |
| 178 fz_halftone *fz_keep_halftone(fz_context *ctx, fz_halftone *half); | |
| 179 | |
| 180 /** | |
| 181 Drop a reference to the halftone. When the reference count | |
| 182 reaches zero, the halftone is destroyed. | |
| 183 | |
| 184 Never throws exceptions. | |
| 185 */ | |
| 186 void fz_drop_halftone(fz_context *ctx, fz_halftone *ht); | |
| 187 | |
| 188 #endif |
