64 HGDIOBJ original = NULL;
77 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
81 clipregion = CreateRectRgnIndirect(&
plot_clip);
82 if (clipregion == NULL) {
89 original = SelectObject(
plot_hdc,GetStockObject(DC_PEN));
91 SelectObject(
plot_hdc, GetStockObject(DC_PEN));
92 SelectObject(
plot_hdc, GetStockObject(DC_BRUSH));
99 DeleteObject(clipregion);
125#ifdef WINDOWS_GDI_ALPHA_WORKED
126 BLENDFUNCTION blnd = { AC_SRC_OVER, 0, 0xff, AC_SRC_ALPHA };
129 bmihdc = CreateCompatibleDC(hdc);
131 bltres = AlphaBlend(hdc,
144 BITMAPINFOHEADER bmih;
145 int v, vv, vi, h, hh, width4, transparency;
147 bool isscaled =
false;
152 NSLOG(plot, DEEPDEBUG,
"%p bitmap %d,%d width %d height %d",
154 NSLOG(plot, DEEPDEBUG,
"clipped %ld,%ld to %ld,%ld",
158 Memhdc = CreateCompatibleDC(hdc);
159 if (Memhdc == NULL) {
165 NSLOG(plot, DEEPDEBUG,
"scaling from %d,%d to %d,%d",
174 bmi = (BITMAPINFO *) malloc(
sizeof(BITMAPINFOHEADER) +
189 SelectObject(Memhdc, MemBMh);
191 GetObject(MemBMh,
sizeof(BITMAP), &MemBM);
193 bmih.biSize =
sizeof(bmih);
197 bmih.biBitCount = 32;
198 bmih.biCompression = BI_RGB;
200 bmih.biXPelsPerMeter = 3600;
201 bmih.biYPelsPerMeter = 3600;
203 bmih.biClrImportant = 0;
204 bmi->bmiHeader = bmih;
206 GetDIBits(hdc, MemBMh, 0,
bitmap->
height, bmi->bmiColors, bmi,
215 for (h = 0, hh = 0; h <
bitmap->
width; h++, hh += 4) {
219 bmi->bmiColors[vv + h].rgbBlue =
221 bmi->bmiColors[vv + h].rgbGreen =
223 bmi->bmiColors[vv + h].rgbRed =
225 }
else if (alpha > 0) {
226 transparency = 0x100 - alpha;
227 bmi->bmiColors[vv + h].rgbBlue =
228 (bmi->bmiColors[vv + h].rgbBlue
232 bmi->bmiColors[vv + h].rgbGreen =
233 (bmi->bmiColors[vv + h].
238 bmi->bmiColors[vv + h].rgbRed =
239 (bmi->bmiColors[vv + h].rgbRed
248 (
const void *) bmi->bmiColors,
249 bmi, DIB_RGB_COLORS);
257 DeleteObject(MemBMh);
292 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
296 clipregion = CreateRectRgnIndirect(&
plot_clip);
297 if (clipregion == NULL) {
301 SelectClipRgn(
plot_hdc, clipregion);
309 bltres = SetDIBitsToDevice(
plot_hdc,
320 SetStretchBltMode(
plot_hdc, COLORONCOLOR);
337 NSLOG(plot, DEEPDEBUG,
"bltres = %d", bltres);
343 DeleteObject(clipregion);
390 int radius,
int angle1,
int angle2)
392 NSLOG(plot, DEEPDEBUG,
"arc centre %d,%d radius %d from %d to %d", x, y, radius,
397 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
401 HRGN clipregion = CreateRectRgnIndirect(&
plot_clip);
402 if (clipregion == NULL) {
407 HPEN pen = CreatePen(PS_GEOMETRIC | PS_SOLID, 1, col);
409 DeleteObject(clipregion);
412 HGDIOBJ penbak = SelectObject(
plot_hdc, (HGDIOBJ) pen);
413 if (penbak == NULL) {
414 DeleteObject(clipregion);
420 double a1=1.0, a2=1.0, b1=1.0, b2=1.0;
421 q1 = (int) ((angle1 + 45) / 90) - 45;
422 q2 = (int) ((angle2 + 45) / 90) - 45;
431 angle1 = ((angle1 + 45) % 90) - 45;
432 angle2 = ((angle2 + 45) % 90) - 45;
437 b1 = -tan((
M_PI / 180) * angle1);
441 a1 = -tan((
M_PI / 180) * angle1);
445 b1 = tan((
M_PI / 180) * angle1);
449 a1 = tan((
M_PI / 180) * angle1);
456 b2 = -tan((
M_PI / 180) * angle2);
460 a2 = -tan((
M_PI / 180) * angle2);
464 b2 = tan((
M_PI / 180) * angle2);
468 a2 = tan((
M_PI / 180) * angle2);
472 SelectClipRgn(
plot_hdc, clipregion);
474 Arc(
plot_hdc, x - radius, y - radius, x + radius, y + radius,
475 x + (
int)(a1 * radius), y + (
int)(b1 * radius),
476 x + (
int)(a2 * radius), y + (
int)(b2 * radius));
479 pen = SelectObject(
plot_hdc, penbak);
480 DeleteObject(clipregion);
502 int x,
int y,
int radius)
504 NSLOG(plot, DEEPDEBUG,
"disc at %d,%d radius %d", x, y, radius);
508 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
512 HRGN clipregion = CreateRectRgnIndirect(&
plot_clip);
513 if (clipregion == NULL) {
519 HPEN pen = CreatePen(PS_GEOMETRIC | PS_SOLID, 1, col);
521 DeleteObject(clipregion);
524 HGDIOBJ penbak = SelectObject(
plot_hdc, (HGDIOBJ) pen);
525 if (penbak == NULL) {
526 DeleteObject(clipregion);
530 HBRUSH brush = CreateSolidBrush(col);
532 DeleteObject(clipregion);
537 HGDIOBJ brushbak = SelectObject(
plot_hdc, (HGDIOBJ) brush);
538 if (brushbak == NULL) {
539 DeleteObject(clipregion);
546 SelectClipRgn(
plot_hdc, clipregion);
549 Arc(
plot_hdc, x - radius, y - radius, x + radius, y + radius,
550 x - radius, y - radius,
551 x - radius, y - radius);
553 Ellipse(
plot_hdc, x - radius, y - radius, x + radius, y + radius);
557 pen = SelectObject(
plot_hdc, penbak);
558 brush = SelectObject(
plot_hdc, brushbak);
559 DeleteObject(clipregion);
583 NSLOG(plot, DEEPDEBUG,
"from %d,%d to %d,%d",
588 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
592 HRGN clipregion = CreateRectRgnIndirect(&
plot_clip);
593 if (clipregion == NULL) {
599 DWORD penstyle = PS_GEOMETRIC |
603 LOGBRUSH lb = {BS_SOLID, col, 0};
604 HPEN pen = ExtCreatePen(penstyle,
608 DeleteObject(clipregion);
611 HGDIOBJ bak = SelectObject(
plot_hdc, (HGDIOBJ) pen);
614 DeleteObject(clipregion);
618 SelectClipRgn(
plot_hdc, clipregion);
628 DeleteObject(clipregion);
652 NSLOG(plot, DEEPDEBUG,
"rectangle from %d,%d to %d,%d",
657 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
661 HRGN clipregion = CreateRectRgnIndirect(&
plot_clip);
662 if (clipregion == NULL) {
666 COLORREF pencol = (DWORD)(style->
stroke_colour & 0x00FFFFFF);
667 DWORD penstyle = PS_GEOMETRIC |
672 LOGBRUSH lb = {BS_SOLID, pencol, 0};
675 lb1.lbStyle = BS_HOLLOW;
677 HPEN pen = ExtCreatePen(penstyle,
683 HGDIOBJ penbak = SelectObject(
plot_hdc, (HGDIOBJ) pen);
684 if (penbak == NULL) {
688 HBRUSH brush = CreateBrushIndirect(&lb1);
694 HGDIOBJ brushbak = SelectObject(
plot_hdc, (HGDIOBJ) brush);
695 if (brushbak == NULL) {
702 SelectClipRgn(
plot_hdc, clipregion);
707 pen = SelectObject(
plot_hdc, penbak);
708 brush = SelectObject(
plot_hdc, brushbak);
712 DeleteObject(clipregion);
738 NSLOG(plot, DEEPDEBUG,
"polygon %d points", n);
742 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
748 HRGN clipregion = CreateRectRgnIndirect(&
plot_clip);
749 if (clipregion == NULL) {
753 COLORREF pencol = (DWORD)(style->
fill_colour & 0x00FFFFFF);
754 COLORREF brushcol = (DWORD)(style->
fill_colour & 0x00FFFFFF);
755 HPEN pen = CreatePen(PS_GEOMETRIC | PS_NULL, 1, pencol);
757 DeleteObject(clipregion);
760 HPEN penbak = SelectObject(
plot_hdc, pen);
761 if (penbak == NULL) {
762 DeleteObject(clipregion);
766 HBRUSH brush = CreateSolidBrush(brushcol);
768 DeleteObject(clipregion);
773 HBRUSH brushbak = SelectObject(
plot_hdc, brush);
774 if (brushbak == NULL) {
775 DeleteObject(clipregion);
782 for (i = 0; i < n; i++) {
783 points[i].
x = (long) p[2 * i];
784 points[i].
y = (long) p[2 * i + 1];
786 NSLOG(plot, DEEPDEBUG,
"%ld,%ld ", points[i].x, points[i].y);
789 SelectClipRgn(
plot_hdc, clipregion);
797 pen = SelectObject(
plot_hdc, penbak);
798 brush = SelectObject(
plot_hdc, brushbak);
799 DeleteObject(clipregion);
825 const float transform[6])
827 NSLOG(plot, DEEPDEBUG,
"path unimplemented");
874 NSLOG(netsurf, INFO,
"Passed null bitmap!");
888 if (!(repeat_x || repeat_y)) {
933 NSLOG(plot, DEEPDEBUG,
"Tiled plotting %d,%d by %d,%d", x, y,
width,
height);
934 NSLOG(plot, DEEPDEBUG,
"clipped %ld,%ld to %ld,%ld",
948 NSLOG(plot, DEEPDEBUG,
"repeat from %d,%d to %ld,%ld",
985 NSLOG(plot, DEEPDEBUG,
"words %s at %d,%d",
text, x, y);
989 NSLOG(netsurf, INFO,
"HDC not set on call to plotters");
993 HRGN clipregion = CreateRectRgnIndirect(&
plot_clip);
994 if (clipregion == NULL) {
998 HFONT fontbak, font =
get_font(fstyle);
1000 DeleteObject(clipregion);
1006 fontbak = (HFONT) SelectObject(
plot_hdc, font);
1009 SelectClipRgn(
plot_hdc, clipregion);
1011 SetTextAlign(
plot_hdc, TA_BASELINE | TA_LEFT);
1012 if ((fstyle->
background & 0xFF000000) != 0x01000000) {
1019 wlen = MultiByteToWideChar(CP_UTF8, 0,
text, length, NULL, 0);
1020 wstring = malloc(2 * (wlen + 1));
1021 if (wstring == NULL) {
1024 MultiByteToWideChar(CP_UTF8, 0,
text, length, wstring, wlen);
1025 TextOutW(
plot_hdc, x, y, wstring, wlen);
1029 font = SelectObject(
plot_hdc, fontbak);
1030 DeleteObject(clipregion);
1050 .option_knockout =
true,
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
struct bitmap * bitmap_scale(struct bitmap *prescale, int width, int height)
HFONT get_font(const plot_font_style_t *style)
The interface to the win32 font and utf8 handling.
Core mouse and pointer states.
Target independent plotting interface.
unsigned long bitmap_flags_t
Interface to platform-specific graphical user interface window operations.
#define NSLOG(catname, level, logmsg, args...)
#define plot_style_fixed_to_int(v)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_DASH
Dashed plot.
@ PLOT_OP_TYPE_DOT
Dotted plot.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
int height
height of bitmap
bool opaque
Whether the bitmap is opaque.
colour foreground
Colour of text.
colour background
Background colour to blend to, if appropriate.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_style_fixed stroke_width
Width of stroke, in pixels.
plot_operation_type_t fill_type
Fill plot type.
colour stroke_colour
Colour of stroke.
plot_operation_type_t stroke_type
Stroke plot type.
Plotter operations table.
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
uint32_t colour
Colour type: XBGR.
UTF-8 manipulation functions (interface).
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror plot_bitmap(struct bitmap *bitmap, int x, int y, int width, int height)
Internal bitmap plotting.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror plot_alpha_bitmap(HDC hdc, struct bitmap *bitmap, int x, int y, int width, int height)
plot an alpha blended bitmap
static nserror plot_block(COLORREF col, int x, int y, int width, int height)
bitmap helper to plot a solid block of colour
static nserror arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
const struct plotter_table win_plotters
win32 API plot operation table
static RECT plot_clip
currently set clipping rectangle
static nserror disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
static nserror rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
static nserror polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.