123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*
- * pixiv_down - CLI-based downloading tool for https://www.pixiv.net.
- * Copyright (C) 2024 Mio
- *
- * 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, version 3 of the License.
- *
- * 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/>.
- */
- module pd.image_reader.posix;
- version(PD_USE_MAGICK):
- import core.stdc.string;
- import pd.imaging.magick;
- import std.string;
- import std.experimental.logger;
- public class ImageReader
- {
- this(string filename)
- {
- fHandle = NewMagickWand();
- MagickReadImage(fHandle, toStringz(filename));
- fHandle.SetImageDispose(PreviousDispose);
- }
- ~this()
- {
- dispose(false);
- }
- void dispose()
- {
- dispose(true);
- }
- MagickWand* getSystemRef() {
- return this.fHandle;
- }
- private:
- MagickWand* fHandle;
- bool fDisposed = false;
- void dispose(bool disposing)
- {
- if (fDisposed) {
- return;
- }
- if (disposing) {
- if (null !is fHandle) {
- DestroyMagickWand(fHandle);
- }
- }
- fDisposed = true;
- }
- }
|