update dlib dependency

This commit is contained in:
Vadim Lopatin 2014-12-30 12:17:58 +03:00
parent 5282fa9e00
commit 27de6fae12
3 changed files with 40 additions and 28 deletions

View File

@ -5,6 +5,9 @@
"license": "Boost", "license": "Boost",
"authors": ["Vadim Lopatin"], "authors": ["Vadim Lopatin"],
"targetType": "none", "targetType": "none",
"buildRequirements":[
"allowWarnings"
],
"subPackages": [ "subPackages": [
{ {
"name": "dlanguilib", "name": "dlanguilib",
@ -92,7 +95,7 @@
"derelict-gl3": "~master", "derelict-gl3": "~master",
"derelict-ft": "~master", "derelict-ft": "~master",
"de_image:png": ">=0.2.3", "de_image:png": ">=0.2.3",
"dlib": "~master" "dlib": ">=0.4.0"
}, },
"-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"] "-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"]
}, },

View File

@ -376,7 +376,7 @@ extern (C) int UIAppMain(string[] args) {
layout.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT); layout.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT);
tabs.addTab(layout, "Tab 1"d); tabs.addTab(layout, "Misc"d);
static if (true) { static if (true) {
// two long lists // two long lists
@ -534,9 +534,7 @@ extern (C) int UIAppMain(string[] args) {
table.margins(Rect(10,10,10,10)).layoutWidth(FILL_PARENT); table.margins(Rect(10,10,10,10)).layoutWidth(FILL_PARENT);
tabs.addTab(table, "TAB_TABLE_LAYOUT"c); tabs.addTab(table, "TAB_TABLE_LAYOUT"c);
tabs.addTab((new TextWidget()).id("tab5").textColor(0x00802000).text("Tab 5 contents"), "Tab 5"d); //tabs.addTab((new TextWidget()).id("tab5").textColor(0x00802000).text("Tab 5 contents"), "Tab 5"d);
tabs.addTab((new SampleAnimationWidget("tab6")).layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT), "TAB_ANIMATION"c);
//========================================================================== //==========================================================================
// create Editors test tab // create Editors test tab
@ -707,6 +705,9 @@ extern (C) int UIAppMain(string[] args) {
tabs.addTab(treeLayout, "Tree"d); tabs.addTab(treeLayout, "Tree"d);
tabs.addTab((new SampleAnimationWidget("tab6")).layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT), "TAB_ANIMATION"c);
//========================================================================== //==========================================================================
contentLayout.addChild(tabs); contentLayout.addChild(tabs);

View File

@ -34,6 +34,7 @@ version (USE_DEIMAGE) {
version (USE_DLIBIMAGE) { version (USE_DLIBIMAGE) {
import dlib.image.io.io; import dlib.image.io.io;
import dlib.image.image; import dlib.image.image;
//version = ENABLE_DLIBIMAGE_JPEG;
} }
import dlangui.core.logger; import dlangui.core.logger;
@ -45,29 +46,7 @@ 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_DLIBIMAGE) { version (USE_DEIMAGE) {
try {
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);
}
}
destroy(image);
return buf;
} catch (Exception e) {
Log.e("Failed to load image from file ", filename, " using dlib image");
Log.e(to!string(e));
return null;
}
} else version (USE_DEIMAGE) {
try { try {
Image image = imageFromFile(filename); Image image = imageFromFile(filename);
int w = cast(int)image.width; int w = cast(int)image.width;
@ -90,6 +69,35 @@ ColorDrawBuf loadImage(string filename) {
Log.e(to!string(e)); Log.e(to!string(e));
return null; return null;
} }
} else version (USE_DLIBIMAGE) {
import std.algorithm;
try {
version (ENABLE_DLIBIMAGE_JPEG) {
} else {
// temporary disabling of JPEG support - until DLIB included it
if (filename.endsWith(".jpeg") || filename.endsWith(".jpg") || filename.endsWith(".JPG") || filename.endsWith(".JPEG"))
return null;
}
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);
}
}
destroy(image);
return buf;
} catch (Exception e) {
Log.e("Failed to load image from file ", filename, " using dlib image");
Log.e(to!string(e));
return null;
}
} else { } else {
try { try {
std.stream.File f = new std.stream.File(filename); std.stream.File f = new std.stream.File(filename);