Skip to content

Commit

Permalink
FEAT: MOLD on image using flat result if image is small enough (les…
Browse files Browse the repository at this point in the history
…s than 10 pixels)

Implements: #13
  • Loading branch information
Oldes committed Jan 28, 2020
1 parent c8510f1 commit 65a0685
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/t-image.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i)
Append_Byte(mold->series, '}');
return;
}

// use `flat` result for images with less than 10 pixels (looks better in console)
if (size < 10) indented = FALSE;

data = (REBCNT *)VAL_IMAGE_DATA(value);
up = Prep_Uni_Series(mold, indented ? ((size * 6) + ((size - 1) / 10) + 1) : (size * 6));

Expand Down
6 changes: 5 additions & 1 deletion src/tests/units/mold-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,16 @@ Rebol [
--assert "make image! [10x0 #{}]" = mold make image! 10x0
--assert "make image! [0x10 #{}]" = mold make image! 0x10

--test-- "mold small image"
;@@ https://github.com/Oldes/Rebol3/issues/13
--assert (mold make image! 2x2) = {make image! [2x2 #{FFFFFFFFFFFFFFFFFFFFFFFF}]}

--test-- "mold/flat image!"
;@@ https://github.com/rebol/rebol-issues/issues/2389
--assert (mold/flat make image! 8x1) = {make image! [8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
--assert (mold/flat make image! 8x2) = {make image! [8x2 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
--assert (mold/flat make image! [1x1 0.0.0.66]) = {make image! [1x1 #{000000} #{42}]}

--test-- "mold/flat/all image!"
--assert (mold/all/flat make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
--assert (mold/all/flat next make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} 2]}
Expand Down

0 comments on commit 65a0685

Please sign in to comment.