PNG Byte Swap at runtime
-
10-06-2021 - |
Domanda
I've got an app that is generating thumbnails of images at runtime. But they're not in the optimized format that Xcode creates when images are added to a project. Is there a library or a function call I can use to convert these images?
Soluzione
Instructions:
- Download DHowett (thanks, DHowett!) code from: https://github.com/DHowett/pincrush
- Unzip and rename to DHowett and place next to the XCode sample project I placed (https://www.box.com/s/7dfb3e6f430d98d933c2), and run...
If/When you build your own project from scratch, then do the following immediately after unzipping and BEFORE adding the folder to your project:
- Remove all makefile files from the folder
- Drag the folder to your project
- To overcome compiler warning "implicit declartion of function 'pincrush' is invalid in C99", changed project setting "C Language Dialect" to "GNU89"
- When building, you'll get an error "'png.h" file not found" - to fix it, add DHowett/libpng to the project's Header Search Paths
- open pincrush.c and comment out the "usage" and "main" functions (you don't need them, and the first causes compilation error, the second causes link errors)
- Add an external reference to crush... See below: extern void crush(const char *infilename, const char *outfilename);
- You can ignore the 8 compilation warnings of "Unused Entity Issue" caused by the "NEXT" macro
You may need to remove the .git* files from the project (some annyoing warnings...)
Enjoy, good luck!
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow