Code Monkey home page Code Monkey logo

windrawlib's People

Contributors

antonioscuri avatar carlo-bramini avatar denchetverikov avatar dirkschulze avatar mity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windrawlib's Issues

Need suggestion for wdDrawString performance increase

Hello and thanks for this library. Though I am an experienced software engineer, this is my first time using Windows graphics. My app needs to render a large window pixel by pixel at 60 frames per second and this direct2d library is getting the job done. The problem is that after the frame is rendered, it needs to be overlayed with many text labels. The text never changes. Right now, I am calling wdDrawString many times for each frame. This makes 60 frames per second difficult to achieve. Because the text never changes, it seems like there should be a way to prepare it one time, and reuse it over and over. But I do not see how to do that. If I could prepare the text overlay once and convert it to a bit map form, then I could merged it into the rendered bitmap efficiently.

wdBitBltCachedImage() crashes.

When using Direct2D backend, calling wdBitBltCachedImage() usually result in a crash in dummy_ID2D1Bitmap_GetPixelSize()

Cannot build with MinGW-w64

The compilation fails under MingGW-w64 (stock install):

d:\Work\Code\windrawlib>mingw32-make
[  3%] Building C object src/CMakeFiles/windrawlib.dir/backend-d2d.c.obj
[  7%] Building C object src/CMakeFiles/windrawlib.dir/backend-dwrite.c.obj
[ 11%] Building C object src/CMakeFiles/windrawlib.dir/backend-gdix.c.obj
[ 14%] Building C object src/CMakeFiles/windrawlib.dir/backend-wic.c.obj
[ 18%] Building C object src/CMakeFiles/windrawlib.dir/bitblt.c.obj
D:\Work\Code\windrawlib\src\bitblt.c: In function 'wdBitBltImage':
D:\Work\Code\windrawlib\src\bitblt.c:52:85: error: macro "ID2D1RenderTarget_CreateBitmapFromWicBitmap" passed 4 arguments, but takes just 3
         hr = ID2D1RenderTarget_CreateBitmapFromWicBitmap(c->target, bitmap, NULL, &b);
                                                                                     ^
D:\Work\Code\windrawlib\src\bitblt.c:52:14: error: 'ID2D1RenderTarget_CreateBitmapFromWicBitmap' undeclared (first use in this function)
         hr = ID2D1RenderTarget_CreateBitmapFromWicBitmap(c->target, bitmap, NULL, &b);
              ^
D:\Work\Code\windrawlib\src\bitblt.c:52:14: note: each undeclared identifier is reported only once for each function it appears in
D:\Work\Code\windrawlib\src\bitblt.c:37:27: warning: unused variable 'bitmap' [-Wunused-variable]
         IWICBitmapSource* bitmap = (IWICBitmapSource*) hImage;
                           ^
src\CMakeFiles\windrawlib.dir\build.make:162: recipe for target 'src/CMakeFiles/windrawlib.dir/bitblt.c.obj' failed
mingw32-make[2]: *** [src/CMakeFiles/windrawlib.dir/bitblt.c.obj] Error 1
CMakeFiles\Makefile2:84: recipe for target 'src/CMakeFiles/windrawlib.dir/all' failed
mingw32-make[1]: *** [src/CMakeFiles/windrawlib.dir/all] Error 2
Makefile:82: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

MinGW-w64/gcc version used:

d:\Work\Code\windrawlib>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/dev/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 -
-with-sysroot=/c/mingw530/x86_64-530-win32-seh-rt_v4-rev0/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --ena
ble-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libato
mic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-versio
n-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror -
-disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw530/prerequisi
tes/x86_64-w64-mingw32-static --with-mpfr=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw530/prerequisites/x86_64-w64-mingw32-
static --with-isl=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-seh-rev0, Built by MinGW-W64 project' --with-bug
url=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-win32-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prereq
uisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-win32-s
eh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include
' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw530/x86_64-530-win32-seh-rt_v4-rev0/mingw64/opt/lib -L/c/mingw530/prerequisites/x86_64-zlib-static/lib -L/c/mingw
530/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 5.3.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)

Create canvas with HDC by GetDC and GetWindowDC counld't destroy resources

My code:

void effects(...) {
    ...
    dc = GetDC(hwnd);
    canvas = wdCreateCanvasWithHDC(dc, &rect, 0);
    wdBeginPaint(canvas);

    for (int i = 0; i < 20; i++) {
        brush = wdCreateSolidBrush(canvas, WD_RGB(0,0,0));
        wdDestroyBrush(brush);
    }
    
    wdEndPaint(canvas);
    wdDestroyCanvas(canvas);
}
  • The function is called, memory increase by time, the brushes and other resources (from windrawlib) are not destroyed.
  • This function was on another thread, I've changed D2D1 Factory creating flag to multithreaded (0x1), but got the same. I've turned to main thread, no difference.

StrokeStyles: Antialiasing & GDI+ backend

@antonioscuri

With GDI+ backend, anti-aliasing causes bad artifacts, especially with small stroke widths (1.0f):

bad screenshot

It can be worked around by applying some 0.5f offset corrections, for example for the horizontal lines here, I have added +0.5f to its X coordinates:

corrected horiz. lines

However that can be tricky for some other paint functions, e.g. wdDrawRectStyled(): I was not able to paint a square with wdDrawRect() where it would help for all its lines at the same time...

IMHO the ideal case would be, that when painting just horizontal or vertical lines, and using coordinates placing both line ends exactly into pixel grid (i.e. that there are no anti-aliasing needed for solid line), then all the dashes and dots for the default patterns (or ideally even custom ones, if they use just integers in its pattern) would also fit exactly into pixel grid.

Could maybe GdipGetPenDashOffset() be used to achieve that? Or any other idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.