diff --git a/src/core/t-image.c b/src/core/t-image.c index a45bcc1716..46e51eb2b4 100644 --- a/src/core/t-image.c +++ b/src/core/t-image.c @@ -433,6 +433,7 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i) REBCNT size; REBCNT *data; REBYTE* pixel; + REBOOL indented = !GET_MOPT(mold, MOPT_INDENT); Emit(mold, "IxI #{", VAL_IMAGE_WIDE(value), VAL_IMAGE_HIGH(value)); @@ -444,18 +445,18 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i) return; } data = (REBCNT *)VAL_IMAGE_DATA(value); - up = Prep_Uni_Series(mold, (size * 6) + ((size - 1) / 10) + 1); + up = Prep_Uni_Series(mold, indented ? ((size * 6) + ((size - 1) / 10) + 1) : (size * 6)); for (len = 0; len < size; len++) { pixel = (REBYTE*)data++; - if ((len % 10) == 0) *up++ = LF; + if (indented && (len % 10) == 0) *up++ = LF; up = Form_RGB_Uni(up, TO_RGBA_COLOR(pixel[C_R], pixel[C_G], pixel[C_B], pixel[C_A])); } // Output Alpha channel, if it has one: if (Image_Has_Alpha(value, FALSE)) { - - Append_Bytes(mold->series, "\n} #{"); + if (indented) Append_Byte(mold->series, '\n'); + Append_Bytes(mold->series, "} #{"); up = Prep_Uni_Series(mold, (size * 2) + (size / 10) + 1); @@ -467,7 +468,10 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i) } *up = 0; // tail already set from Prep. - Append_Bytes(mold->series, "\n}"); + if (indented) + Append_Bytes(mold->series, "\n}"); + else + Append_Byte(mold->series, '}'); } diff --git a/src/tests/units/mold-test.r3 b/src/tests/units/mold-test.r3 index c8afbbf861..38bc9d0400 100644 --- a/src/tests/units/mold-test.r3 +++ b/src/tests/units/mold-test.r3 @@ -269,6 +269,15 @@ Rebol [ --assert "make image! [10x0 #{}]" = mold make image! 10x0 --assert "make image! [0x10 #{}]" = mold make image! 0x10 + --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}]} + + --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]} + ===end-group=== ~~~end-file~~~