diff --git a/README.md b/README.md index 439380d..1f08e91 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ Included are plugins for: - Finder - macOS - GNOME - Linux - [GIMP](https://www.gimp.org) - Windows/macOS/Linux -- [Imagine](http://www.nyam.pe.kr/dev/imagine/) - Windows - [Paint.NET](https://www.getpaint.net) - Windows - [XnView](https://www.xnview.com) - Windows/macOS/Linux diff --git a/win32/.gitignore b/win32/.gitignore index a05a82b..407f6fe 100644 --- a/win32/.gitignore +++ b/win32/.gitignore @@ -1,6 +1,4 @@ QOI.o QOI32.o -QOI.plg -QOI.plg64 Xqoi32.usr signed diff --git a/win32/ImagPlug.h b/win32/ImagPlug.h deleted file mode 100644 index d3c39e0..0000000 --- a/win32/ImagPlug.h +++ /dev/null @@ -1,518 +0,0 @@ -#ifndef _IMAGPLUG_H_ -#define _IMAGPLUG_H_ - -typedef struct IMAGINEPLUGINFILEINFOTABLE IMAGINEPLUGINFILEINFOTABLE; -typedef struct IMAGINEPLUGINARCHIVEINFOTABLE IMAGINEPLUGINARCHIVEINFOTABLE; -typedef struct IMAGINEARCHIVE IMAGINEARCHIVE; - -#define IMAGINEAPI __stdcall - -#define IMAGINEPLUGININTERFACE_VERSION_NUMBER1 1 -#define IMAGINEPLUGININTERFACE_VERSION_NUMBER2 0 -#define IMAGINEPLUGININTERFACE_VERSION_NUMBER3 8 -#define IMAGINEPLUGININTERFACE_VERSION_NUMBER4 0 // unused -#define IMAGINEPLUGININTERFACE_VERSION ((IMAGINEPLUGININTERFACE_VERSION_NUMBER1<<24)|(IMAGINEPLUGININTERFACE_VERSION_NUMBER2<<16)|(IMAGINEPLUGININTERFACE_VERSION_NUMBER3<<8)|(IMAGINEPLUGININTERFACE_VERSION_NUMBER4<<0)) - -#if (!defined(UNICODE)) - #define ImaginePluginGetInfo ImaginePluginGetInfoA - #define IMAGINEPLUGIN_ENTRYPROCNAME "ImaginePluginGetInfoA" -#else - #define ImaginePluginGetInfo ImaginePluginGetInfoW - #define IMAGINEPLUGIN_ENTRYPROCNAME "ImaginePluginGetInfoW" -#endif - -#if (defined(_WIN64)) - #define IMAGINEPLUGIN_EXTENSION "plg64" -#else - #define IMAGINEPLUGIN_EXTENSION "plg" -#endif - -#define IMAGINEERROR_NOERROR 0 -#define IMAGINEERROR_UNSUPPORTEDTYPE 1 -#define IMAGINEERROR_UNKNOWNERROR 2 -#define IMAGINEERROR_OUTOFMEMORY 3 -#define IMAGINEERROR_COLORNOTSUPPORTED 4 -#define IMAGINEERROR_READERROR 5 -#define IMAGINEERROR_WRITEERROR 6 -#define IMAGINEERROR_INVALIDDATA 7 -#define IMAGINEERROR_FILENOTFOUND 8 -#define IMAGINEERROR_ABORTED 9 -#define IMAGINEERROR_GRAYSCALEONLY 10 -#define IMAGINEERROR_OTHERCOMPONENTSREQUIRED 11 -#define IMAGINEERROR_SIZENOTSUPPORTED 12 -#define IMAGINEERROR_GETINFONOTSUPPORTED 13 - -#define IMAGINECOMPRESSION_NONE 0 -#define IMAGINECOMPRESSION_RLE 1 -#define IMAGINECOMPRESSION_PACKBITS 2 -#define IMAGINECOMPRESSION_LZW 3 -#define IMAGINECOMPRESSION_ZIP 4 -#define IMAGINECOMPRESSION_JPEG 5 -#define IMAGINECOMPRESSION_WAVELET 6 -#define IMAGINECOMPRESSION_HUFFMANRLE 7 -#define IMAGINECOMPRESSION_FAX3 8 -#define IMAGINECOMPRESSION_FAX4 9 -#define IMAGINECOMPRESSION_JBIG 10 -#define IMAGINECOMPRESSION_JPEGXR 11 -#define IMAGINECOMPRESSION_VP8 12 - -#define IMAGINELOADPARAM_OPTION 1 -#define IMAGINELOADPARAM_CALLBACK 2 -#define IMAGINELOADPARAM_TEST 4 -#define IMAGINELOADPARAM_FIRSTFRAMEONLY 8 -#define IMAGINELOADPARAM_DETECTEXTENSION 16 -#define IMAGINELOADPARAM_FIRSTPAGEONLY 32 -#define IMAGINELOADPARAM_SPECIFYFILE_TYPE 64 -#define IMAGINELOADPARAM_GETINFO 128 -#define IMAGINELOADPARAM_CLEAR 256 -#define IMAGINELOADPARAM_NEARESTSIZE 512 -#define IMAGINELOADPARAM_ZOOM 1024 -#define IMAGINELOADPARAM_GETFILETIME 2048 -#define IMAGINELOADPARAM_GETEXIF 4096 - -#define IMAGINESAVEPARAM_OPTION 1 -#define IMAGINESAVEPARAM_CALLBACK 2 -#define IMAGINESAVEPARAM_TEST 4 -#define IMAGINESAVEPARAM_FIRSTFRAMEONLY 8 -#define IMAGINESAVEPARAM_ADJUSTCOLOR 16 -#define IMAGINESAVEPARAM_FIRSTPAGEONLY 32 - -#define IMAGINECAPS_ZOOM 1 -#define IMAGINECAPS_MULTIFRAME 2 -#define IMAGINECAPS_MULTIPAGE 4 -#define IMAGINECAPS_TRANSPARENCYCOLOR 8 -#define IMAGINECAPS_TRANSPARENCYMASK 16 -#define IMAGINECAPS_ALPHA 32 -#define IMAGINECAPS_GRAYSCALE 64 -#define IMAGINECAPS_INTERLACED 128 -#define IMAGINECAPS_PROGRESSIVE 256 -#define IMAGINECAPS_BOTTOMUP 512 -#define IMAGINECAPS_NEARESTSIZE 1024 -#define IMAGINECAPS_TEXTCALLBACK 2048 - -#define IMAGINETRANSMETHOD_NONE 0 -#define IMAGINETRANSMETHOD_COLOR 1 -#define IMAGINETRANSMETHOD_MASK 2 -#define IMAGINETRANSMETHOD_ALPHABLEND 3 - -#define IMAGINEEQUALIZEPARAM_CALLBACK 1 - -#define IMAGINEOPTIONITEM_CHECKBOX 0 -#define IMAGINEOPTIONITEM_SCROLLBAR 1 -#define IMAGINEOPTIONITEM_EDIT 2 -#define IMAGINEOPTIONITEM_COMBOBOX 3 - -#define IMAGINELOADERPARAM_QUITONDESTROY 1 -#define IMAGINELOADERPARAM_CMDSHOW 2 - -#define IMAGINECHILDPARAM_I_AM_IN_LISTER 1 - -#define WM_IMAGINE_LOADEROPEN (WM_USER+0x108) -#define WM_IMAGINE_LOADERFITIMAGE (WM_USER+0x109) - -typedef DWORD IMAGINECOLOR; - -typedef LPVOID LPIMAGINEBITMAP; -typedef LPVOID LPIMAGINEPALETTE; - -#define IMAGINECHILD_VIEWPARAM_SET_IMAGE_FIT_MODE 1 -#define IMAGINECHILD_VIEWPARAM_SET_CENTER_IMAGE 2 - -typedef struct IMAGINECHILD_VIEWPARAM -{ - int flags; - int imageFitMode; - BOOL centerImage; -} IMAGINECHILD_VIEWPARAM; - -typedef struct IMAGINECHILDCREATEPARAM -{ - int flags; -} IMAGINECHILDCREATEPARAM; - -typedef struct IMAGINELOADERCREATEPARAM -{ - int flags; - int cmdShow; - - LPCTSTR commandLine; -} IMAGINELOADERCREATEPARAM; - -typedef struct IMAGINESMARTBUFFER -{ - int size; - int additionalAllocUnitSize; - char *buffer; - char *current; - char *tail; -} IMAGINESMARTBUFFER; - -typedef struct IMAGINECALLBACKPARAM -{ - LPIMAGINEBITMAP dib; - LPVOID param; - int current; - int overall; - LPCSTR message; -} IMAGINECALLBACKPARAM; - -typedef BOOL (IMAGINEAPI *IMAGINECALLBACKPROC)(IMAGINECALLBACKPARAM *callbackParam); - -typedef struct IMAGINECALLBACK -{ - IMAGINECALLBACKPROC proc; - LPVOID param; -} IMAGINECALLBACK; - -typedef struct IMAGINELOADOPTION -{ - BYTE reserved[32]; -} IMAGINELOADOPTION; - -typedef struct IMAGINESAVEOPTION -{ - BYTE reserved[64]; -} IMAGINESAVEOPTION; - -#define IMAGINEADJUSTCOLORANSWER_NO 0 -#define IMAGINEADJUSTCOLORANSWER_YES 1 -#define IMAGINEADJUSTCOLORANSWER_CANCEL 2 -#define IMAGINEADJUSTCOLORANSWER_CHOOSEANOTHER 3 - -typedef int (IMAGINEAPI *IMAGINESAVEADJUSTCOLORPROMPTPROC)(IMAGINECALLBACKPARAM *callbackParam); - -typedef struct IMAGINESAVEADJUSTCOLORPROMPT -{ - IMAGINESAVEADJUSTCOLORPROMPTPROC proc; - LPVOID param; -} IMAGINESAVEADJUSTCOLORPROMPT; - -typedef struct IMAGINESAVEADJUSTCOLOR -{ - LPVOID saveBufferProc; - IMAGINESAVEADJUSTCOLORPROMPT prompt; - LPVOID quantizeInfoTable; -} IMAGINESAVEADJUSTCOLOR; - -typedef struct IMAGINEZOOMPARAM -{ - int numerator; - int denominator; -} IMAGINEZOOMPARAM; - -typedef struct IMAGINELOADPARAM -{ - DWORD length; - LPVOID buffer; - LPVOID fileInfo; - IMAGINELOADOPTION option; - IMAGINEZOOMPARAM zoom; - SIZE size; - IMAGINECALLBACK callback; - DWORD errorCode; - DWORD caps; - FILETIME fileTime; - - // Private - LPCTSTR fileName; -} IMAGINELOADPARAM; - -typedef struct IMAGINESAVEPARAM -{ - LPCTSTR fileType; - IMAGINESAVEOPTION option; - IMAGINECALLBACK callback; - DWORD errorCode; - DWORD caps; - IMAGINESMARTBUFFER *sb; - - // Private - LPVOID saveBufferProc; - IMAGINESAVEADJUSTCOLOR adjustColor; -} IMAGINESAVEPARAM; - -typedef struct IMAGINEFILTERPARAM -{ - LPCTSTR filterType; - - DWORD errorCode; -} IMAGINEFILTERPARAM; - -typedef struct IMAGINEFILTERPROCESSINFO -{ - const LONG *kernel; - LONG Ksize; - LONG Kfactor; - LONG Koffset; -} IMAGINEFILTERPROCESSINFO; - -typedef struct IMAGINEFILTERPROCESSPARAM -{ - // Public - const IMAGINEFILTERPROCESSINFO *info; - - DWORD errorCode; -} IMAGINEFILTERPROCESSPARAM; - -typedef struct IMAGINEEQUALIZEPARAM -{ - IMAGINECALLBACK callback; - - DWORD errorCode; -} IMAGINEEQUALIZEPARAM; - -typedef struct IMAGINEOPTIONITEMCOMBOBOX -{ - int itemCount; - const LPCTSTR *itemString; -} IMAGINEOPTIONITEMCOMBOBOX; - -typedef struct IMAGINEOPTIONITEMSCROLLBAR -{ - int min; - int max; -} IMAGINEOPTIONITEMSCROLLBAR; - -typedef union IMAGINEOPTIONITEMCUSTOM -{ - IMAGINEOPTIONITEMCOMBOBOX combobox; - IMAGINEOPTIONITEMSCROLLBAR scrollbar; -} IMAGINEOPTIONITEMCUSTOM; - -typedef struct IMAGINEOPTIONITEM -{ - int type; - LPCTSTR text; - DWORD dwDefault; - const IMAGINEOPTIONITEMCUSTOM *custom; -} IMAGINEOPTIONITEM; - -typedef struct IMAGINEOPTION -{ - int itemCount; - const IMAGINEOPTIONITEM *item; -} IMAGINEOPTION; - -typedef struct IMAGINEFILEINFOITEM -{ - BOOL (IMAGINEAPI *checkFileTypeProc)(IMAGINEPLUGINFILEINFOTABLE *table,IMAGINELOADPARAM *param,int flags); - LPIMAGINEBITMAP (IMAGINEAPI *loadBufferProc)(IMAGINEPLUGINFILEINFOTABLE *table,IMAGINELOADPARAM *param,int flags); - BOOL (IMAGINEAPI *saveBufferProc)(IMAGINEPLUGINFILEINFOTABLE *table,LPIMAGINEBITMAP bitmap,IMAGINESAVEPARAM *param,int flags); - LPCTSTR fileType; - LPCTSTR extension; - LPVOID reserved; - const IMAGINEOPTION *option; -} IMAGINEFILEINFOITEM; - -typedef struct IMAGINEFILEINFO -{ - IMAGINEFILEINFOITEM item; - - BOOL isActive; - struct IMAGINEFILEINFO *next; - struct IMAGINEFILEINFO *prev; -} IMAGINEFILEINFO; - -typedef struct IMAGINEFILTERINFOITEM -{ - IMAGINEFILTERPROCESSINFO info; - LPIMAGINEBITMAP (IMAGINEAPI *Filter)(LPVOID table,LPIMAGINEBITMAP bitmap,IMAGINEFILTERPARAM *filterParam,int flags); - LPCTSTR filterType; -} IMAGINEFILTERINFOITEM; - -typedef struct IMAGINEFILTERINFO -{ - IMAGINEFILTERINFOITEM item; - - BOOL isActive; - struct IMAGINEFILTERINFO *next; - struct IMAGINEFILTERINFO *prev; -} IMAGINEFILTERINFO; - -#define IMAGINEARCHIVE_PROCESS_OPERATION_SKIP 0 -#define IMAGINEARCHIVE_PROCESS_OPERATION_EXTRACT 1 - -typedef struct IMAGINEARCHIVEINFOITEM -{ - LPCTSTR archiveType; - LPCTSTR extension; - BOOL (__stdcall *checkArchiveProc)(IMAGINEPLUGINARCHIVEINFOTABLE *archiveInfoTable,LPCTSTR fileName); - BOOL (__stdcall *openArchiveProc)(IMAGINEPLUGINARCHIVEINFOTABLE *archiveInfoTable,IMAGINEARCHIVE *archive,LPCTSTR fileName); - BOOL (__stdcall *readHeaderProc)(IMAGINEPLUGINARCHIVEINFOTABLE *archiveInfoTable,IMAGINEARCHIVE *archive,WIN32_FIND_DATA *wfd); - BOOL (__stdcall *processFileProc)(IMAGINEPLUGINARCHIVEINFOTABLE *archiveInfoTable,IMAGINEARCHIVE *archive,int operation,LPVOID buffer,DWORD bufferLength); - BOOL (__stdcall *closeArchiveProc)(IMAGINEPLUGINARCHIVEINFOTABLE *archiveInfoTable,IMAGINEARCHIVE *archive); -} IMAGINEARCHIVEINFOITEM; - -typedef struct IMAGINEARCHIVEINFO -{ - IMAGINEARCHIVEINFOITEM item; - - BOOL isActive; - struct IMAGINEARCHIVEINFO *next; - struct IMAGINEARCHIVEINFO *prev; -} IMAGINEARCHIVEINFO; - -struct IMAGINEARCHIVE -{ - IMAGINEARCHIVEINFO *archiveInfo; - LPVOID lParam; -}; - -typedef struct IMAGINEPLUGININTERFACEVTBL -{ - IMAGINEFILEINFO *(IMAGINEAPI *RegisterFileType)(const IMAGINEFILEINFOITEM *item); - LPIMAGINEBITMAP (IMAGINEAPI *Create)(LONG width,LONG height,LONG bitCount,int flags); - LPIMAGINEBITMAP (IMAGINEAPI *CreateMask)(LONG width,LONG height); - BOOL (IMAGINEAPI *Destroy)(LPIMAGINEBITMAP bitmap); - LONG (IMAGINEAPI *GetWidth)(LPIMAGINEBITMAP bitmap); - LONG (IMAGINEAPI *GetHeight)(LPIMAGINEBITMAP bitmap); - LONG (IMAGINEAPI *GetBitCount)(LPIMAGINEBITMAP bitmap); - LPVOID (IMAGINEAPI *GetBits)(LPIMAGINEBITMAP bitmap); - LONG (IMAGINEAPI *GetWidthBytes)(LPIMAGINEBITMAP bitmap); - LONG (IMAGINEAPI *GetPureWidthBytes)(LPIMAGINEBITMAP bitmap); - LONG (IMAGINEAPI *GetLength)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *GetPalette)(LPIMAGINEBITMAP bitmap,LPPALETTEENTRY paletteEntry); - BOOL (IMAGINEAPI *SetPalette)(LPIMAGINEBITMAP bitmap,LPPALETTEENTRY paletteEntry); - IMAGINESMARTBUFFER *(IMAGINEAPI *sbAlloc)(int initialSize,int additionalAllocUnitSize); - LPVOID (IMAGINEAPI *sbWrite)(IMAGINESMARTBUFFER *sb,LPVOID dest,LPCVOID src,int length); - LPVOID (IMAGINEAPI *Alloc)(int size); - VOID (IMAGINEAPI *Free)(LPVOID block); - BOOL (IMAGINEAPI *UtilImportPalette)(LPPALETTEENTRY palette,LPVOID data,int entryCount,int entryType); - BOOL (IMAGINEAPI *UtilExportPalette)(LPPALETTEENTRY palette,LPVOID data,int entryCount,int entryType); - BOOL (IMAGINEAPI *UtilCreateGrayscalePalette)(LPPALETTEENTRY palette,int entryCount); - LONG (IMAGINEAPI *UtilGetBitCountFromColorCount)(LONG nColorCount); - int (IMAGINEAPI *Get16BitMode)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *Set16BitMode)(LPIMAGINEBITMAP bitmap,int mode); - int (IMAGINEAPI *GetTransMethod)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *SetTransMethod)(LPIMAGINEBITMAP bitmap,int transMethod); - IMAGINECOLOR (IMAGINEAPI *GetTransColor)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *SetTransColor)(LPIMAGINEBITMAP bitmap,IMAGINECOLOR color); - LPIMAGINEBITMAP (IMAGINEAPI *GetTransMask)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *SetTransMask)(LPIMAGINEBITMAP bitmap,LPIMAGINEBITMAP mask); - LPIMAGINEBITMAP (IMAGINEAPI *TransConvertMethod)(LPIMAGINEBITMAP bitmap,int transMethod); - BOOL (IMAGINEAPI *PageAddFrame)(LPIMAGINEBITMAP bitmap,LPIMAGINEBITMAP prev); - LPIMAGINEBITMAP (IMAGINEAPI *PageGetNext)(LPIMAGINEBITMAP bitmap); - LPIMAGINEBITMAP (IMAGINEAPI *PageGetPrev)(LPIMAGINEBITMAP bitmap); - DWORD (IMAGINEAPI *PageGetFrameCount)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *AnimAddFrame)(LPIMAGINEBITMAP bitmap,LPIMAGINEBITMAP prev); - BOOL (IMAGINEAPI *AnimDeleteFrame)(LPIMAGINEBITMAP bitmap); - LPIMAGINEBITMAP (IMAGINEAPI *AnimGetNext)(LPIMAGINEBITMAP bitmap); - LPIMAGINEBITMAP (IMAGINEAPI *AnimGetPrev)(LPIMAGINEBITMAP bitmap); - LPIMAGINEBITMAP (IMAGINEAPI *AnimGetHead)(LPIMAGINEBITMAP bitmap); - LPIMAGINEBITMAP (IMAGINEAPI *AnimGetTail)(LPIMAGINEBITMAP bitmap); - DWORD (IMAGINEAPI *AnimGetDelay)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *AnimSetDelay)(LPIMAGINEBITMAP bitmap,DWORD delay); - DWORD (IMAGINEAPI *AnimGetFrameCount)(LPIMAGINEBITMAP bitmap); - LPIMAGINEBITMAP (IMAGINEAPI *AnimGetFrame)(LPIMAGINEBITMAP bitmap,int frameNumber); - int (IMAGINEAPI *AnimGetFrameNumber)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *GetFocus)(LPIMAGINEBITMAP bitmap,LPPOINT pt); - BOOL (IMAGINEAPI *SetFocus)(LPIMAGINEBITMAP bitmap,LPPOINT pt); - DWORD (IMAGINEAPI *GetCompression)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *SetCompression)(LPIMAGINEBITMAP bitmap,DWORD compression); - IMAGINECOLOR (IMAGINEAPI *GetPixel)(LPIMAGINEBITMAP bitmap,int x,int y); - BOOL (IMAGINEAPI *PutPixel)(LPIMAGINEBITMAP bitmap,int x,int y,IMAGINECOLOR color); - IMAGINECOLOR (IMAGINEAPI *GetPixelColor)(LPIMAGINEBITMAP bitmap,int x,int y); - BOOL (IMAGINEAPI *PutPixelColor)(LPIMAGINEBITMAP bitmap,int x,int y,IMAGINECOLOR color); - LPIMAGINEPALETTE (IMAGINEAPI *PaletteCreate)(LPPALETTEENTRY entry,int entryCount); - BOOL (IMAGINEAPI *PaletteDestroy)(LPIMAGINEPALETTE palette); - int (IMAGINEAPI *PaletteGetEntryNumber)(LPIMAGINEPALETTE palette); - LPPALETTEENTRY (IMAGINEAPI *PaletteGetEntry)(LPIMAGINEPALETTE palette,int entryNumber); - int (IMAGINEAPI *PaletteGetNearestIndex)(LPIMAGINEPALETTE palette,LPPALETTEENTRY color); - LPIMAGINEBITMAP (IMAGINEAPI *Copy)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *Flip)(LPIMAGINEBITMAP bitmap); - IMAGINEFILTERINFO *(IMAGINEAPI *RegisterFilterType)(const IMAGINEFILTERINFOITEM *item); - LPIMAGINEBITMAP (IMAGINEAPI *Filter)(LPIMAGINEBITMAP bitmap,IMAGINEFILTERPARAM *filterParam,int flags); - LPIMAGINEBITMAP (IMAGINEAPI *FilterProcess)(LPIMAGINEBITMAP bitmap,IMAGINEFILTERPROCESSPARAM *filterProcessParam,int flags); - LPIMAGINEBITMAP (IMAGINEAPI *LoadFile)(LPCTSTR fileName,IMAGINELOADPARAM *loadParam,int flags); - DWORD (IMAGINEAPI *SaveFile)(LPIMAGINEBITMAP bitmap,LPCTSTR fileName,IMAGINESAVEPARAM *dsp,int flags); - IMAGINEFILEINFO *(IMAGINEAPI *GetFileInfo)(LPIMAGINEBITMAP bitmap); - IMAGINEFILEINFO *(IMAGINEAPI *GetFileType)(LPCTSTR fileType); - BOOL (IMAGINEAPI *GetFileExtension)(IMAGINEFILEINFO *info,LPTSTR buffer,int extensionNumber); - IMAGINEFILEINFO *(IMAGINEAPI *GetFileInfoWithExtension)(LPCTSTR extension); - LPIMAGINEBITMAP (IMAGINEAPI *Equalize)(LPIMAGINEBITMAP bitmap,IMAGINEEQUALIZEPARAM *equalizeParam,int flags); - BOOL (IMAGINEAPI *SaveAdjustColor)(IMAGINESAVEPARAM *saveParam,IMAGINESAVEADJUSTCOLORPROMPT *prompt); - BOOL (IMAGINEAPI *SaveOptionLoad)(IMAGINEFILEINFO *info,IMAGINESAVEOPTION *saveOption,LPCTSTR fileName); - LPVOID (IMAGINEAPI *BSearch)(LPCVOID key,LPCVOID base,int num,int width,int (__cdecl *compare)(LPCVOID,LPCVOID)); - VOID (IMAGINEAPI *QSort)(LPVOID base,int num,int width,int (__cdecl *compare)(LPCVOID,LPCVOID)); - BOOL (IMAGINEAPI *UtilCheckGrayscalePalette)(LPPALETTEENTRY palette,int entryCount); - BOOL (IMAGINEAPI *PageGetMipMap)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *PageSetMipMap)(LPIMAGINEBITMAP bitmap,BOOL isMipMapAvailable); - BOOL (IMAGINEAPI *TestFile)(LPCTSTR fileName); - HWND (IMAGINEAPI *ChildCreate)(HWND hwnd,LPCTSTR fileName,IMAGINECHILDCREATEPARAM *createParam); - HWND (IMAGINEAPI *LoaderCreate)(HWND hwnd,LPCTSTR commandLine,IMAGINELOADERCREATEPARAM *createParam); - BOOL (IMAGINEAPI *CopyClipboard)(HWND hwnd); - BOOL (IMAGINEAPI *Redraw)(HWND hwnd,BOOL eraseBackground); - HBITMAP (IMAGINEAPI *GetPreviewBitmap)(LPCTSTR fileName,LONG width,LONG height); - LPCTSTR (IMAGINEAPI *OptionGetFileName)(VOID); - LPWINDOWPLACEMENT (IMAGINEAPI *LoaderGetPosition)(HWND hwnd); - BOOL (IMAGINEAPI *PrintDialog)(HWND hwnd); - LPVOID (IMAGINEAPI *GetLineBits)(LPIMAGINEBITMAP bitmap,int y); - BOOL (IMAGINEAPI *ChildOpenFileName)(HWND hwnd,LPCTSTR fileName); - BOOL (IMAGINEAPI *ChildViewSetParam)(HWND hwnd,IMAGINECHILD_VIEWPARAM *viewParam); - BOOL (IMAGINEAPI *SlideShow)(HWND parent,LPVOID header); - IMAGINEARCHIVEINFO *(IMAGINEAPI *RegisterArchiveType)(const IMAGINEARCHIVEINFOITEM *item); - int (IMAGINEAPI *ANSIToUnicode)(LPWSTR unicodeString,int bufferCount,LPCSTR ansiString,int count); - int (IMAGINEAPI *UnicodeToANSI)(LPSTR ansiString,int bufferCount,LPCWSTR unicodeString,int count); - HANDLE (IMAGINEAPI *CreateFile)(LPCTSTR lpFileName,DWORD dwDesiredAccess,DWORD dwShareMode,LPSECURITY_ATTRIBUTES lpSecurityAttributes,DWORD dwCreationDistribution,DWORD dwFlagsAndAttributes,HANDLE hTemplateFile); - BOOL (IMAGINEAPI *ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped); - BOOL (IMAGINEAPI *WriteFile)(HANDLE hFile,LPCVOID lpBuffer,DWORD nNumberOfBytesToWrite,LPDWORD lpNumberOfBytesWritten,LPOVERLAPPED lpOverlapped); - DWORD (IMAGINEAPI *SetFilePointer)(HANDLE hFile,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod); - BOOL (IMAGINEAPI *CloseHandle)(HANDLE hObject); - VOID (IMAGINEAPI *sbFree)(IMAGINESMARTBUFFER *sb); - BOOL (IMAGINEAPI *CreateMultipleFrameWindow)(HWND parent,LPVOID param); - BOOL (IMAGINEAPI *SaveDialog)(HWND parent,LPVOID param); - LPIMAGINEBITMAP (IMAGINEAPI *LoadBuffer)(IMAGINELOADPARAM *loadParam,int flags); - BOOL (IMAGINEAPI *SetFileInfo)(LPIMAGINEBITMAP bitmap,const IMAGINEFILEINFO *fileInfo); - BOOL (IMAGINEAPI *IsUnicode)(VOID); - LPVOID (IMAGINEAPI *AllocUserBuffer)(LPIMAGINEBITMAP bitmap,DWORD length); - LPCTSTR (IMAGINEAPI *GetCompressionText)(LPIMAGINEBITMAP bitmap); - BOOL (IMAGINEAPI *SetCompressionText)(LPIMAGINEBITMAP bitmap,LPCTSTR compressionText); - int (IMAGINEAPI *sbSeek)(IMAGINESMARTBUFFER *sb,long offset,int origin); -} IMAGINEPLUGININTERFACEVTBL; - -typedef struct IMAGINEPLUGININTERFACE -{ - const IMAGINEPLUGININTERFACEVTBL *lpVtbl; -} IMAGINEPLUGININTERFACE; - -struct IMAGINEPLUGINFILEINFOTABLE -{ - IMAGINEFILEINFO *head; - IMAGINEFILEINFO *tail; - const IMAGINEPLUGININTERFACE *iface; -}; - -struct IMAGINEPLUGINARCHIVEINFOTABLE -{ - IMAGINEARCHIVEINFO *head; - IMAGINEARCHIVEINFO *tail; - const IMAGINEPLUGININTERFACE *iface; -}; - -typedef BOOL (IMAGINEAPI *IMAGINEPLUGINREGISTERPROC)(const IMAGINEPLUGININTERFACE *iface); - -typedef struct IMAGINEPLUGININFOA -{ - DWORD size; - IMAGINEPLUGINREGISTERPROC registerProc; - DWORD versionNumber; - LPCSTR description; - DWORD usedInterfaceVersionNumber; -} IMAGINEPLUGININFOA; - -typedef struct IMAGINEPLUGININFOW -{ - DWORD size; - IMAGINEPLUGINREGISTERPROC registerProc; - DWORD versionNumber; - LPCWSTR description; - DWORD usedInterfaceVersionNumber; -} IMAGINEPLUGININFOW; - -#if (defined(UNICODE)) - #define IMAGINEPLUGININFO IMAGINEPLUGININFOW -#else - #define IMAGINEPLUGININFO IMAGINEPLUGININFOA -#endif - -#endif diff --git a/win32/qoiimagine.c b/win32/qoiimagine.c deleted file mode 100644 index a08ba96..0000000 --- a/win32/qoiimagine.c +++ /dev/null @@ -1,200 +0,0 @@ -// qoiimagine.c - QOI Imagine plugin -// -// Copyright (C) 2021-2022 Piotr Fusik -// -// MIT License: -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include -#include - -#include "ImagPlug.h" -#include "QOI.h" - -static BOOL IMAGINEAPI checkFile(IMAGINEPLUGINFILEINFOTABLE *fileInfoTable, IMAGINELOADPARAM *loadParam, int flags) -{ - return loadParam->length > 4 && memcmp(loadParam->buffer, "qoif", 4) == 0; -} - -static LPIMAGINEBITMAP IMAGINEAPI loadFile(IMAGINEPLUGINFILEINFOTABLE *fileInfoTable, IMAGINELOADPARAM *loadParam, int flags) -{ - const IMAGINEPLUGININTERFACE *iface = fileInfoTable->iface; - if (iface == NULL) - return NULL; - - QOIDecoder *qoi = QOIDecoder_New(); - if (qoi == NULL) { - loadParam->errorCode = IMAGINEERROR_OUTOFMEMORY; - return NULL; - } - if (!QOIDecoder_Decode(qoi, loadParam->buffer, loadParam->length)) { - QOIDecoder_Delete(qoi); - loadParam->errorCode = IMAGINEERROR_UNSUPPORTEDTYPE; - return NULL; - } - int width = QOIDecoder_GetWidth(qoi); - int height = QOIDecoder_GetHeight(qoi); - const int *pixels = QOIDecoder_GetPixels(qoi); - bool alpha = QOIDecoder_HasAlpha(qoi); - - LPIMAGINEBITMAP bitmap = iface->lpVtbl->Create(width, height, alpha ? 32 : 24, flags); - if (bitmap == NULL) { - QOIDecoder_Delete(qoi); - loadParam->errorCode = IMAGINEERROR_OUTOFMEMORY; - return NULL; - } - if (alpha) - iface->lpVtbl->SetTransMethod(bitmap, IMAGINETRANSMETHOD_ALPHABLEND); - if ((flags & IMAGINELOADPARAM_GETINFO) != 0) { - QOIDecoder_Delete(qoi); - return bitmap; - } - - IMAGINECALLBACKPARAM param; - param.dib = bitmap; - param.param = loadParam->callback.param; - param.overall = height - 1; - param.message = NULL; - for (int y = 0; y < height; y++) { - LPBYTE dest = (LPBYTE) iface->lpVtbl->GetLineBits(bitmap, y); - if (alpha) - memcpy(dest, pixels + y * width, width << 2); - else { - for (int x = 0; x < width; x++) { - int rgb = *pixels++; - // 0xRRGGBB -> 0xBB 0xGG 0xRR - *dest++ = (BYTE) rgb; - *dest++ = (BYTE) (rgb >> 8); - *dest++ = (BYTE) (rgb >> 16); - } - } - if ((flags & IMAGINELOADPARAM_CALLBACK) != 0) { - param.current = y; - if (!loadParam->callback.proc(¶m)) { - QOIDecoder_Delete(qoi); - loadParam->errorCode = IMAGINEERROR_ABORTED; - return bitmap; - } - } - } - QOIDecoder_Delete(qoi); - return bitmap; -} - -static BOOL IMAGINEAPI saveFile(IMAGINEPLUGINFILEINFOTABLE *fileInfoTable, LPIMAGINEBITMAP bitmap, IMAGINESAVEPARAM *saveParam, int flags) -{ - const IMAGINEPLUGININTERFACE *iface = fileInfoTable->iface; - if (iface == NULL) - return FALSE; - - bool alpha; - switch (iface->lpVtbl->GetBitCount(bitmap)) { - case 24: - alpha = false; - break; - case 32: - alpha = true; - break; - default: - saveParam->errorCode = IMAGINEERROR_COLORNOTSUPPORTED; - return FALSE; - } - int width = iface->lpVtbl->GetWidth(bitmap); - int height = iface->lpVtbl->GetHeight(bitmap); - if (!QOIEncoder_CanEncode(width, height, alpha)) { - saveParam->errorCode = IMAGINEERROR_SIZENOTSUPPORTED; - return FALSE; - } - if ((flags & IMAGINESAVEPARAM_TEST) != 0) - return TRUE; - - int *pixels = (int *) malloc(width * height * sizeof(int)); - if (pixels == NULL) { - saveParam->errorCode = IMAGINEERROR_OUTOFMEMORY; - return FALSE; - } - for (int y = 0; y < height; y++) { - LPCBYTE src = (LPCBYTE) iface->lpVtbl->GetLineBits(bitmap, y); - if (alpha) - memcpy(pixels + y * width, src, width << 2); - else { - for (int x = 0; x < width; x++) { - // 0xBB 0xGG 0xRR -> 0xRRGGBB - pixels[y * width + x] = src[2] << 16 | src[1] << 8 | src[0]; - src += 3; - } - } - } - - QOIEncoder *qoi = QOIEncoder_New(); - if (qoi == NULL) { - free(pixels); - saveParam->errorCode = IMAGINEERROR_OUTOFMEMORY; - return FALSE; - } - bool ok = QOIEncoder_Encode(qoi, width, height, pixels, alpha, false); - free(pixels); - if (!ok) { - QOIEncoder_Delete(qoi); - saveParam->errorCode = IMAGINEERROR_SIZENOTSUPPORTED; - return FALSE; - } - int encodedSize = QOIEncoder_GetEncodedSize(qoi); - - saveParam->sb = iface->lpVtbl->sbAlloc(encodedSize, 0); - if (saveParam->sb == NULL) { - QOIEncoder_Delete(qoi); - saveParam->errorCode = IMAGINEERROR_OUTOFMEMORY; - return FALSE; - } - ok = iface->lpVtbl->sbWrite(saveParam->sb, saveParam->sb->current, QOIEncoder_GetEncoded(qoi), encodedSize) != NULL; - QOIEncoder_Delete(qoi); - if (!ok) { - saveParam->errorCode = IMAGINEERROR_WRITEERROR; - return FALSE; - } - return TRUE; -} - -static BOOL IMAGINEAPI registerProcW(const IMAGINEPLUGININTERFACE *iface) -{ - static const IMAGINEFILEINFOITEM fileInfoItemW = { - checkFile, - loadFile, - saveFile, - (LPCTSTR) L"Quite OK Image (QOI)", - (LPCTSTR) L"QOI\0" - }; - return iface->lpVtbl->RegisterFileType(&fileInfoItemW) != NULL; -} - -__declspec(dllexport) BOOL IMAGINEAPI ImaginePluginGetInfoW(IMAGINEPLUGININFOW *dest) -{ - static const IMAGINEPLUGININFOW pluginInfoW = { - sizeof(pluginInfoW), - registerProcW, - 0x02000000, - L"QOI Plugin", - IMAGINEPLUGININTERFACE_VERSION - }; - *dest = pluginInfoW; - return TRUE; -} diff --git a/win32/setup/qoi-fu.wxs b/win32/setup/qoi-fu.wxs index 3dccb6e..509e185 100644 --- a/win32/setup/qoi-fu.wxs +++ b/win32/setup/qoi-fu.wxs @@ -109,21 +109,6 @@ - - - - - - - - - - - - - - - @@ -201,19 +186,6 @@ - - - - - - - - - - - - - @@ -247,14 +219,6 @@ - - - - - - - - diff --git a/win32/win32.mk b/win32/win32.mk index 2c34a2c..bbf0594 100644 --- a/win32/win32.mk +++ b/win32/win32.mk @@ -1,6 +1,4 @@ CXXFLAGS = -O2 -Wall -IMAGINE_DIR = $(LOCALAPPDATA)/Imagine -IMAGINE32_DIR = $(LOCALAPPDATA)/Imagine32 XNVIEW32_DIR = C:/Program Files (x86)/XnView CC32 = i686-w64-mingw32-gcc CXX32 = i686-w64-mingw32-g++ @@ -21,24 +19,12 @@ win32/QOI.o: transpiled/QOI.c win32/QOI32.o: transpiled/QOI.c $(CC32) $(CFLAGS) -c -o $@ $^ -win32/QOI.plg64: win32/qoiimagine.c transpiled/QOI.c - $(CC) $(CFLAGS) -I . -I transpiled -o $@ $^ -shared - -win32/QOI.plg: win32/qoiimagine.c transpiled/QOI.c - $(CC32) $(CFLAGS) -I . -I transpiled -o $@ $^ -shared -Wl,--kill-at - win32/Xqoi32.usr: Xqoi.c QOI-stdio.c QOI-stdio.h transpiled/QOI.c $(CC32) $(CFLAGS) -I transpiled -o $@ $^ -shared -Wl,--kill-at win32/QOIPaintDotNet.dll: win32/QOIPaintDotNet.cs transpiled/QOI.cs $(CSC) -o+ -out:$@ -t:library $^ -nostdlib -r:"$(PAINT_NET_DIR)/PaintDotNet.ComponentModel.dll" -r:"$(PAINT_NET_DIR)/PaintDotNet.Core.dll" -r:"$(PAINT_NET_DIR)/PaintDotNet.Data.dll" -r:"$(PAINT_NET_DIR)/PaintDotNet.Primitives.dll" -r:"$(DOTNET_REF_DIR)/System.Runtime.dll" -install-imagine: win32/QOI.plg64 - cp $< "$(IMAGINE_DIR)/Plugin/QOI.plg64" - -install-imagine32: win32/QOI.plg - cp $< "$(IMAGINE32_DIR)/Plugin/QOI.plg" - install-xnview32: win32/Xqoi32.usr $(SUDO) cp $< "$(XNVIEW32_DIR)/PlugIns/Xqoi32.usr" @@ -46,13 +32,13 @@ install-paint.net: win32/QOIPaintDotNet.dll $(SUDO) cp $< "$(PAINT_NET_DIR)/FileTypes/QOIPaintDotNet.dll" ../qoi-fu-$(VERSION)-win64.msi: win32/setup/qoi-fu.wxs win32/setup/qoi.ico win32/setup/license.rtf win32/setup/dialog.jpg win32/setup/banner.jpg \ - png2qoi.exe file-qoi.exe win32/wicqoi64.dll win32/wicqoi32.dll win32/QOI.plg64 win32/QOI.plg win32/Xqoi32.usr win32/QOIPaintDotNet.dll Xqoi.usr win32/signed + png2qoi.exe file-qoi.exe win32/wicqoi64.dll win32/wicqoi32.dll win32/Xqoi32.usr win32/QOIPaintDotNet.dll Xqoi.usr win32/signed wix build -o $@ -arch x64 -d VERSION=$(VERSION) -ext WixToolset.UI.wixext $< win32/setup/signed: ../qoi-fu-$(VERSION)-win64.msi $(DO_SIGN) -win32/signed: png2qoi.exe win32/wicqoi64.dll win32/wicqoi32.dll file-qoi.exe win32/QOI.plg64 win32/QOI.plg win32/Xqoi32.usr win32/QOIPaintDotNet.dll Xqoi.usr +win32/signed: png2qoi.exe win32/wicqoi64.dll win32/wicqoi32.dll file-qoi.exe win32/Xqoi32.usr win32/QOIPaintDotNet.dll Xqoi.usr $(DO_SIGN) deb64: @@ -78,6 +64,6 @@ mac: ssh mac 'security unlock-keychain ~/Library/Keychains/login.keychain && rm -rf qoi-fu-$(VERSION) && tar xf qoi-fu-$(VERSION).tar.gz && PATH=/usr/local/bin:$$PATH make -C qoi-fu-$(VERSION) macos/qoi-fu-$(VERSION)-macos.dmg' scp mac:qoi-fu-$(VERSION)/macos/qoi-fu-$(VERSION)-macos.dmg .. -CLEAN += win32/wicqoi64.dll win32/wicqoi32.dll win32/QOI.o win32/QOI32.o win32/QOI.plg64 win32/QOI.plg win32/Xqoi32.usr win32/QOIPaintDotNet.dll win32/setup/signed win32/signed +CLEAN += win32/wicqoi64.dll win32/wicqoi32.dll win32/QOI.o win32/QOI32.o win32/Xqoi32.usr win32/QOIPaintDotNet.dll win32/setup/signed win32/signed -.PHONY: install-imagine install-imagine32 install-xnview32 install-paint.net deb64 rpm64 mac +.PHONY: install-xnview32 install-paint.net deb64 rpm64 mac