get rid of FreeImage: use dlib image instead for loading PNGs and BMPs

This commit is contained in:
Vadim Lopatin 2014-12-30 11:19:45 +03:00
parent eb8ca97878
commit 1fc0db9e02
7 changed files with 60 additions and 14 deletions

View File

@ -47,7 +47,7 @@
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png</imppath>
<imppath>3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath />
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>
@ -250,6 +250,37 @@
<File path="..\de_image\source\png\devisualization\image\png\writer_chunks.d" />
<File path="..\de_image\source\png\devisualization\image\png\writer_chunks_IDAT.d" />
</Folder>
<Folder name="dlib_image">
<File path="..\dlib\dlib\image\io\bitio.d" />
<File path="..\dlib\dlib\image\io\bmp.d" />
<File path="..\dlib\dlib\image\color.d" />
<File path="..\dlib\dlib\filesystem\windows\common.d" />
<File path="..\dlib\dlib\core\compound.d" />
<File path="..\dlib\dlib\math\decomposition.d" />
<File path="..\dlib\dlib\filesystem\delegaterange.d" />
<File path="..\dlib\dlib\filesystem\windows\directory.d" />
<File path="..\dlib\dlib\filesystem\dirrange.d" />
<File path="..\dlib\dlib\filesystem\windows\file.d" />
<File path="..\dlib\dlib\filesystem\filesystem.d" />
<File path="..\dlib\dlib\image\io\huffman.d" />
<File path="..\dlib\dlib\image\io\idct.d" />
<File path="..\dlib\dlib\image\image.d" />
<File path="..\dlib\dlib\math\interpolation.d" />
<File path="..\dlib\dlib\image\io\io.d" />
<File path="..\dlib\dlib\image\io\jpeg.d" />
<File path="..\dlib\dlib\math\linsolve.d" />
<File path="..\dlib\dlib\filesystem\local.d" />
<File path="..\dlib\dlib\math\matrix.d" />
<File path="..\dlib\dlib\image\io\png.d" />
<File path="..\dlib\dlib\functional\range.d" />
<File path="..\dlib\dlib\core\stream.d" />
<File path="..\dlib\dlib\image\io\tga.d" />
<File path="..\dlib\dlib\core\tuple.d" />
<File path="..\dlib\dlib\math\utils.d" />
<File path="..\dlib\dlib\image\io\utils.d" />
<File path="..\dlib\dlib\math\vector.d" />
<File path="..\dlib\dlib\image\io\zstream.d" />
</Folder>
<Folder name="win32">
<File path="3rdparty\win32\basetsd.d" />
<File path="3rdparty\win32\basetyps.d" />

View File

@ -21,10 +21,6 @@
"copyFiles": ["res"],
"copyFiles-windows": [
"lib/FreeImage.dll"
],
"sourceFiles": [
"project.ddoc"
],
@ -94,9 +90,9 @@
"dependencies": {
"derelict-sdl2": "~master",
"derelict-gl3": "~master",
"derelict-fi": "~master",
"derelict-ft": "~master",
"de_image:png": ">=0.2.3",
"dlib": ">=0.4.0"
},
"-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"]
},

View File

@ -47,7 +47,7 @@
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png</imppath>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath />
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>

View File

@ -47,7 +47,7 @@
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png</imppath>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath />
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>

View File

@ -47,7 +47,7 @@
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png</imppath>
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib</imppath>
<fileImppath />
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>

Binary file not shown.

View File

@ -21,17 +21,21 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
module dlangui.graphics.images;
//immutable bool USE_FREEIMAGE = true;
//version = USE_FREEIMAGE;
version = USE_DEIMAGE;
//version = USE_DEIMAGE;
version = USE_DLIBIMAGE;
version (USE_DEIMAGE) {
import devisualization.image;
import devisualization.image.png;
}
version (USE_DLIBIMAGE) {
import dlib.image.io.io;
import dlib.image.image;
}
import dlangui.core.logger;
import dlangui.core.types;
import dlangui.graphics.drawbuf;
@ -41,7 +45,22 @@ import std.conv : to;
/// load and decode image from file to ColorDrawBuf, returns null if loading or decoding is failed
ColorDrawBuf loadImage(string filename) {
Log.d("Loading image from file " ~ filename);
version (USE_DEIMAGE) {
version (USE_DLIBIMAGE) {
SuperImage image = dlib.image.io.io.loadImage(filename);
if (!image)
return null;
int w = image.width;
int h = image.height;
ColorDrawBuf buf = new ColorDrawBuf(w, h);
for (int y = 0; y < h; y++) {
uint * dstLine = buf.scanLine(y);
for (int x = 0; x < w; x++) {
auto pixel = image[x, h - 1 - y].convert(8);
dstLine[x] = makeRGBA(pixel.r, pixel.g, pixel.b, 255 - pixel.a);
}
}
return buf;
} else version (USE_DEIMAGE) {
try {
Image image = imageFromFile(filename);
int w = cast(int)image.width;