Skip to content

Commit 6401f7c

Browse files
committed
FIX: fixing simple image blit, so one can scale image gob types, like:
``` im: load %my-picture.png g: make gob! [image: im] g/size/x: im/size/x / 2 view g ```
1 parent dd1edab commit 6401f7c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/os/win32/host-compositor.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static REBXYF Zero_Pair = {0, 0};
281281

282282
case GOBT_IMAGE:
283283
//RL_Print("draw image gob\n");
284-
OS_Blit_Gob_Image(gob, ctx, offset, top_left, bottom_right);
284+
OS_Blit_Gob_Image(gob, ctx, offset, gob_clip.top, gob_clip.left, gob_clip.bottom, gob_clip.right);
285285
break;
286286

287287
#ifdef HAS_WIDGET_GOB
@@ -501,7 +501,7 @@ static REBXYF Zero_Pair = {0, 0};
501501

502502
/***********************************************************************
503503
**
504-
*/ void OS_Blit_Gob_Image(REBGOB *gob, REBCMP* ctx, REBXYI abs_oft, REBXYI dst_oft, REBXYI dst_siz)
504+
*/ void OS_Blit_Gob_Image(REBGOB *gob, REBCMP* ctx, REBXYI abs_oft, REBINT top, REBINT left, REBINT bottom, REBINT right)
505505
/*
506506
** This routine copies a rectangle from a PAN structure to the
507507
** current output device.
@@ -510,11 +510,12 @@ static REBXYF Zero_Pair = {0, 0};
510510
{
511511
//if (!gob || GOB_TYPE(gob) != GOBT_IMAGE || !GOB_CONTENT(gob)) return;
512512

513+
REBSER *img = (REBSER*)GOB_CONTENT(gob);
513514
HDC hdc = ctx->back_DC;
514515
BITMAPINFO BitmapInfo = ctx->bmpInfo;
515516
REBINT mode;
516-
REBINT src_siz_x = ROUND_TO_INT(gob->size.x);
517-
REBINT src_siz_y = ROUND_TO_INT(gob->size.y);
517+
REBINT src_siz_x = IMG_WIDE(img); // real image size
518+
REBINT src_siz_y = IMG_HIGH(img);
518519

519520
mode = SetStretchBltMode(hdc, COLORONCOLOR); // returns previous mode
520521
BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -523,13 +524,13 @@ static REBXYF Zero_Pair = {0, 0};
523524

524525
StretchDIBits(
525526
hdc,
526-
dst_oft.x, dst_oft.y,
527-
dst_siz.x, dst_siz.y,
527+
left, top,
528+
right - left, bottom - top,
528529
0, 0, // always at 0x0 so far; should we support image atlases?
529530
src_siz_x, src_siz_y,
530531
GOB_BITMAP(gob),
531532
&BitmapInfo,
532-
DIB_PAL_COLORS,
533+
DIB_RGB_COLORS,
533534
SRCCOPY
534535
);
535536
SetStretchBltMode(hdc, mode);

0 commit comments

Comments
 (0)