mirror of https://github.com/buggins/dlangui.git
support of using de_image instead of FreeImage - part 1
This commit is contained in:
parent
d5dff418fe
commit
ccaa2aa667
|
@ -47,7 +47,7 @@
|
||||||
<compiler>0</compiler>
|
<compiler>0</compiler>
|
||||||
<otherDMD>0</otherDMD>
|
<otherDMD>0</otherDMD>
|
||||||
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
||||||
<imppath>3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source</imppath>
|
<imppath>3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png</imppath>
|
||||||
<fileImppath />
|
<fileImppath />
|
||||||
<outdir>$(ConfigurationName)</outdir>
|
<outdir>$(ConfigurationName)</outdir>
|
||||||
<objdir>$(OutDir)</objdir>
|
<objdir>$(OutDir)</objdir>
|
||||||
|
@ -234,6 +234,22 @@
|
||||||
<File path="..\DerelictUtil\source\derelict\util\wintypes.d" />
|
<File path="..\DerelictUtil\source\derelict\util\wintypes.d" />
|
||||||
<File path="..\DerelictUtil\source\derelict\util\xtypes.d" />
|
<File path="..\DerelictUtil\source\derelict\util\xtypes.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
|
<Folder name="de_image">
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\chunks.d" />
|
||||||
|
<File path="..\de_image\source\interfaces\devisualization\image\color.d" />
|
||||||
|
<File path="..\de_image\source\interfaces\devisualization\image\creation.d" />
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\defs.d" />
|
||||||
|
<File path="..\de_image\source\interfaces\devisualization\image\image.d" />
|
||||||
|
<File path="..\de_image\source\interfaces\devisualization\image\manipulation.d" />
|
||||||
|
<File path="..\de_image\source\interfaces\devisualization\image\package.d" />
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\package.d" />
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\reader.d" />
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\reader_chunks.d" />
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\reader_chunks_IDAT.d" />
|
||||||
|
<File path="..\de_image\source\png\devisualization\image\png\writer.d" />
|
||||||
|
<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="win32">
|
<Folder name="win32">
|
||||||
<File path="3rdparty\win32\basetsd.d" />
|
<File path="3rdparty\win32\basetsd.d" />
|
||||||
<File path="3rdparty\win32\basetyps.d" />
|
<File path="3rdparty\win32\basetyps.d" />
|
||||||
|
|
3
dub.json
3
dub.json
|
@ -95,7 +95,8 @@
|
||||||
"derelict-sdl2": "~master",
|
"derelict-sdl2": "~master",
|
||||||
"derelict-gl3": "~master",
|
"derelict-gl3": "~master",
|
||||||
"derelict-fi": "~master",
|
"derelict-fi": "~master",
|
||||||
"derelict-ft": "~master"
|
"derelict-ft": "~master",
|
||||||
|
"de_image:png": "~master"
|
||||||
},
|
},
|
||||||
"-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"]
|
"-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"]
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,6 +22,15 @@ module dlangui.graphics.images;
|
||||||
|
|
||||||
immutable bool USE_FREEIMAGE = true;
|
immutable bool USE_FREEIMAGE = true;
|
||||||
|
|
||||||
|
//version = USE_DEIMAGE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
version (USE_DEIMAGE) {
|
||||||
|
import devisualization.image.creation;
|
||||||
|
import devisualization.image.image;
|
||||||
|
}
|
||||||
|
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import dlangui.core.types;
|
import dlangui.core.types;
|
||||||
import dlangui.graphics.drawbuf;
|
import dlangui.graphics.drawbuf;
|
||||||
|
@ -31,6 +40,21 @@ import std.conv : to;
|
||||||
/// load and decode image from file to ColorDrawBuf, returns null if loading or decoding is failed
|
/// load and decode image from file to ColorDrawBuf, returns null if loading or decoding is failed
|
||||||
ColorDrawBuf loadImage(string filename) {
|
ColorDrawBuf loadImage(string filename) {
|
||||||
Log.d("Loading image from file " ~ filename);
|
Log.d("Loading image from file " ~ filename);
|
||||||
|
version (USE_DEIMAGE) {
|
||||||
|
try {
|
||||||
|
Image image = imageFromFile(filename);
|
||||||
|
ColorDrawBuf buf = new ColorDrawBuf(image.width, image.height);
|
||||||
|
Color_RGBA[] pixels = image.rgba.allPixels;
|
||||||
|
for (int y = 0; y < image.height; y++) {
|
||||||
|
// TODO: convert pixels
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
} catch (NotAnImageException e) {
|
||||||
|
Log.e("Failed to load image from file ", filename, " using de_image");
|
||||||
|
Log.e(to!string(e));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
std.stream.File f = new std.stream.File(filename);
|
std.stream.File f = new std.stream.File(filename);
|
||||||
scope(exit) { f.close(); }
|
scope(exit) { f.close(); }
|
||||||
|
@ -40,6 +64,8 @@ ColorDrawBuf loadImage(string filename) {
|
||||||
Log.e(to!string(e));
|
Log.e(to!string(e));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// load and decode image from stream to ColorDrawBuf, returns null if loading or decoding is failed
|
/// load and decode image from stream to ColorDrawBuf, returns null if loading or decoding is failed
|
||||||
|
|
Loading…
Reference in New Issue