mity / windrawlib Goto Github PK
View Code? Open in Web Editor NEWC library for Windows for easy-to-use 2D painting with Direct2D or, on older Windows versions, GDI+.
License: MIT License
C library for Windows for easy-to-use 2D painting with Direct2D or, on older Windows versions, GDI+.
License: MIT License
For WIN10 PRO
Hi,
win/wdl/font.c(53)
warning C4221: nonstandard extension used : 'locales' : cannot be initialized using address of automatic variable 'user_locale'
Is secure ignore this?
Best regards,
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.
When using Direct2D backend, calling wdBitBltCachedImage()
usually result in a crash in dummy_ID2D1Bitmap_GetPixelSize()
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)
For some reason, dots are not painted in the D2D backend:
Dotted style implies no painting. The styles mixing dashes and dots paint just the dashes.
Any idea what can be the culprit?
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);
}
With GDI+ backend, anti-aliasing causes bad artifacts, especially with small stroke widths (1.0f):
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:
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.