2 * Copyright (C) 2020 The Geeqie Team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "image-load-cr3.h"
27 #include "image-load-jpeg.h"
28 #include "image-load.h"
33 struct ImageLoaderCr3 : public ImageLoaderJpeg
36 gboolean write(const guchar *buf, gsize &chunk_size, gsize count, GError **error) override;
37 gchar *get_format_name() override;
38 gchar **get_format_mime_types() override;
41 gboolean ImageLoaderCr3::write(const guchar *buf, gsize &chunk_size, gsize count, GError **error)
43 /** @FIXME Just start search at where full size jpeg should be,
44 * then search through the file looking for a jpeg end-marker
46 gboolean found = FALSE;
51 while (n < count - 4 && !found)
53 if (memcmp(&buf[n], "mdat", 4) == 0)
55 if (memcmp(&buf[n + 12], "\xFF\xD8", 2) == 0)
60 if (memcmp(&buf[n + 12 + i], "\xFF\xD9", 2) == 0)
83 gboolean ret = ImageLoaderJpeg::write(buf + n + 12, chunk_size, i, error);
91 gchar *ImageLoaderCr3::get_format_name()
93 return g_strdup("cr3");
96 gchar **ImageLoaderCr3::get_format_mime_types()
98 static const gchar *mime[] = {"image/x-canon-cr3", nullptr};
99 return g_strdupv(const_cast<gchar **>(mime));
104 std::unique_ptr<ImageLoaderBackend> get_image_loader_backend_cr3()
106 return std::make_unique<ImageLoaderCr3>();
109 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */