mirror of https://github.com/buggins/dlangui.git
tiled images support, part 2
This commit is contained in:
parent
64f5924b8e
commit
ba53e802e6
|
@ -66,7 +66,7 @@
|
|||
<debuglevel>0</debuglevel>
|
||||
<debugids />
|
||||
<versionlevel>0</versionlevel>
|
||||
<versionids>Unicode USE_SDL</versionids>
|
||||
<versionids>Unicode USE_SDL USE_OPENGL</versionids>
|
||||
<dump_source>0</dump_source>
|
||||
<mapverbosity>0</mapverbosity>
|
||||
<createImplib>1</createImplib>
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<debuglevel>0</debuglevel>
|
||||
<debugids />
|
||||
<versionlevel>0</versionlevel>
|
||||
<versionids>Unicode USE_SDL</versionids>
|
||||
<versionids>Unicode USE_SDL USE_OPENGL</versionids>
|
||||
<dump_source>0</dump_source>
|
||||
<mapverbosity>3</mapverbosity>
|
||||
<createImplib>0</createImplib>
|
||||
|
|
|
@ -115,6 +115,8 @@ extern (C) int UIAppMain(string[] args) {
|
|||
// load theme from file "theme_default.xml"
|
||||
Platform.instance.uiTheme = "theme_default";
|
||||
|
||||
//drawableCache.get("tx_fabric.tiled");
|
||||
|
||||
// create window
|
||||
Window window = Platform.instance.createWindow("My Window", null);
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ static if (USE_FREEIMAGE) {
|
|||
//get the image width and height, and size per pixel
|
||||
int width = FreeImage_GetWidth(dib);
|
||||
int height = FreeImage_GetHeight(dib);
|
||||
int stride = FreeImage_GetLine(dib);
|
||||
int bpp = FreeImage_GetBPP(dib);
|
||||
int pixelSize = (bpp + 7)/8;
|
||||
FREE_IMAGE_COLOR_TYPE colorType = FreeImage_GetColorType(dib);
|
||||
|
@ -125,7 +126,7 @@ static if (USE_FREEIMAGE) {
|
|||
transparencyCount = FreeImage_GetTransparencyCount(dib);
|
||||
transparencyTable = FreeImage_GetTransparencyTable(dib);
|
||||
}
|
||||
int size = width*height*pixelSize;
|
||||
//int size = stride*height;
|
||||
|
||||
ColorDrawBuf res = new ColorDrawBuf(width, height);
|
||||
|
||||
|
@ -135,7 +136,7 @@ static if (USE_FREEIMAGE) {
|
|||
uint r, g, b, a;
|
||||
for( int i = 0, ii = height-1; i < height ; ++i, --ii ) {
|
||||
dst = res.scanLine(i);
|
||||
src = data + (ii * width) * pixelSize;
|
||||
src = data + ii * stride;
|
||||
for( int j = 0; j < width; ++j, ++dst, src += pixelSize ) {
|
||||
if (colorType == FIC_PALETTE) {
|
||||
ubyte index = src[0];
|
||||
|
|
|
@ -297,8 +297,22 @@ class ImageDrawable : Drawable {
|
|||
tiley0 %= imgdy;
|
||||
if (tiley0 < 0)
|
||||
tiley0 += imgdy;
|
||||
|
||||
buf.drawRescaled(rc, _image.get, Rect(0, 0, _image.width, _image.height));
|
||||
int xx0 = rc.left;
|
||||
int yy0 = rc.top;
|
||||
if (tilex0)
|
||||
xx0 -= imgdx - tilex0;
|
||||
if (tiley0)
|
||||
yy0 -= imgdy - tiley0;
|
||||
for (int yy = yy0; yy < rc.bottom; yy += imgdy) {
|
||||
for (int xx = xx0; xx < rc.right; xx += imgdx) {
|
||||
Rect dst = Rect(xx, yy, xx + imgdx, yy + imgdy);
|
||||
Rect src = Rect(0, 0, imgdx, imgdy);
|
||||
if (dst.intersects(rc))
|
||||
buf.drawFragment(dst.left, dst.top, _image.get, src);
|
||||
}
|
||||
}
|
||||
buf.drawImage(rc.left + 30, rc.top + 30, _image);
|
||||
buf.drawFrame(Rect(rc.left + 30, rc.top + 30, rc.left + imgdx + 30, rc.top + imgdy + 30), 0x80800000, Rect(2,2,2,2));
|
||||
} else {
|
||||
// rescaled or normal
|
||||
if (rc.width != _image.width || rc.height != _image.height)
|
||||
|
|
Loading…
Reference in New Issue