Commit 8b8e0392 authored by Robert Sprowson's avatar Robert Sprowson

[236] Adjust scaling factors to avoid righthand/bottom edge conditions

source/ChangeFSI: After rounding up the scaled output size, recalculate the div/mul factors so they produce a whole number of pixels instead of falling off the end of the input array and mixing in black.
source/DesktopFE: Remove dead variable "safe%" and change tofitx/tofity to integers.
Minor clarification in CmdBasUse documentation.

Tested with a 100x100 green sprite, scaled by 5:3/5:3 and 3:7/3:7. Fixes ticket #236.

Version 1.59. Tagged as 'ChangeFSI-1_59'
parent f17ade0a
......@@ -106,9 +106,9 @@ Parameters
Use
---
You need to have the ChangeFSI program in the library, or on Run$Path, or to
specify its full pathname on the command line; and you must be running
outside the desktop (e.g. by pressing F12).
You need to have booted the ChangeFSI application which sets up an alias for
the ChangeFSI command; and you must be running outside the desktop (e.g. by
pressing F12).
An hourglass is displayed giving the percentage processed; this may run
through twice for some of the more expensive options. The program reads the
......
/* (1.58)
/* (1.59)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.58
#define Module_MajorVersion_CMHG 1.59
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 21 May 2016
#define Module_Date_CMHG 04 Nov 2016
#define Module_MajorVersion "1.58"
#define Module_Version 158
#define Module_MajorVersion "1.59"
#define Module_Version 159
#define Module_MinorVersion ""
#define Module_Date "21 May 2016"
#define Module_Date "04 Nov 2016"
#define Module_ApplicationDate "21-May-16"
#define Module_ApplicationDate "04-Nov-16"
#define Module_ComponentName "ChangeFSI"
#define Module_ComponentPath "mixed/RiscOS/Sources/Apps/ChangeFSI"
#define Module_FullVersion "1.58"
#define Module_HelpVersion "1.58 (21 May 2016)"
#define Module_LibraryVersionInfo "1:58"
#define Module_FullVersion "1.59"
#define Module_HelpVersion "1.59 (04 Nov 2016)"
#define Module_LibraryVersionInfo "1:59"
......@@ -3040,15 +3040,27 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
NEXT
ENDCASE
ENDIF
REM deal with large ratios
REPEAT
PROCreduce(xmul%,xdiv%)
PROCreduce(ymul%,ydiv%)
IF xdiv%*ydiv%*255>2^32 xdiv%=xdiv% AND NOT 1:ydiv%=ydiv% AND NOT 1:xmul%=xmul% AND NOT 1:ymul%=ymul% AND NOT 1
UNTIL xdiv%*ydiv%*255<2^32
REM deal with large ratios
IF info% PRINT "Size ratios are x ";xmul%":"xdiv%" y "ymul%":"ydiv%
REM Round up to the nearest whole pixel
x%=sx%*xmul%/xdiv%+.9999
y%=sy%*ymul%/ydiv%+.9999
REM Adjust the mul/div ratio to account for the round up operation
adjmul%=x%:adjdiv%=sx%:PROCreduce(adjmul%,adjdiv%)
IF adjmul%<>xmul% OR adjdiv%<>xdiv% THEN
IF info% PRINT "Adjusted x size (from ";xmul%":"xdiv%") to nearest whole pixel"
xmul%=adjmul%:xdiv%=adjdiv%
ENDIF
adjmul%=y%:adjdiv%=sy%:PROCreduce(adjmul%,adjdiv%)
IF adjmul%<>ymul% OR adjdiv%<>ydiv% THEN
IF info% PRINT "Adjusted y size (from ";ymul%":"ydiv%") to nearest whole pixel"
ymul%=adjmul%:ydiv%=adjdiv%
ENDIF
IF info% PRINT "Size ratios are x ";xmul%":"xdiv%" y "ymul%":"ydiv%
rows%=sy%
order%=x%*y%>sx%*sy%:REM TRUE if scaling up
code%=FNdim(8192)
......
......@@ -595,13 +595,13 @@ DEF FNcheckvalues
:
REM
DEF PROCChangeFSISuffix
safe%= TRUE
IF FNgeticonstate(scalew%,1) A$+=" "+ STR$tofitx+": "+ STR$tofity+":":safe%= FALSE
IF FNgeticonstate(scalew%,5) A$+=" 1:2":safe%= FALSE
IF FNgeticonstate(scalew%,4) A$+=" 1:2 1:1":safe%= FALSE
IF FNgeticonstate(scalew%,3) A$+=" 1:1 1:2":safe%= FALSE
IF FNgeticonstate(scalew%,1) A$+=" "+ STR$tofitx%+": "+ STR$tofity%+":"
REM geticonstate(scalew%,2) no op 1:1 1:1
IF FNgeticonstate(scalew%,3) A$+=" 1:1 1:2"
IF FNgeticonstate(scalew%,4) A$+=" 1:2 1:1"
IF FNgeticonstate(scalew%,5) A$+=" 1:2"
IF FNgeticonstate(scalew%,9) THEN
safe%= FALSE
REM Custom scaling
IF VAL $s%(0) A$+=" "+$s%(0) ELSE A$+=" 1"
A$+=":"+$s%(1)
IF VAL $s%(2) A$+=" "+$s%(2) ELSE A$+=" 1"
......@@ -611,19 +611,18 @@ DEF PROCChangeFSISuffix
IF FNgeticonstate(scalew%,18) A$+=" -noscale"
IF FNgeticonstate(scalew%,19) A$+=" -lock"
IF FNgeticonstate(scalew%,6) THEN
safe%= FALSE
IF FNgeticonstate(scalew%,16) A$+=" -rotate" ELSE A$+=" -rotate-"
ENDIF
IF FNgeticonstate(scalew%,7) A$+=" -hflip":safe%= FALSE
IF FNgeticonstate(scalew%,8) A$+=" -vflip":safe%= FALSE
IF FNgeticonstate(proc%,0) A$+=" -range":safe%= FALSE
IF FNgeticonstate(proc%,1) A$+=" -equal":safe%= FALSE
IF FNgeticonstate(scalew%,7) A$+=" -hflip"
IF FNgeticonstate(scalew%,8) A$+=" -vflip"
IF FNgeticonstate(proc%,0) A$+=" -range"
IF FNgeticonstate(proc%,1) A$+=" -equal"
IF FNgeticonstate(proc%,2) A$+=" -nodither"
IF FNgeticonstate(proc%,3) A$+=" -invert":safe%= FALSE
IF FNgeticonstate(proc%,3) A$+=" -invert"
IF FNgeticonstate(proc%,4) A$+=" -brighten"
IF FNgeticonstate(proc%,5) A$+=" -black"+$p%(0)
IF FNgeticonstate(proc%,6) A$+=" -gamma"+FNlocale_convert($p%(1),decimal_point$,"."):safe%= FALSE
IF FNgeticonstate(proc%,7) A$+=" -sharpen"+$p%(2):safe%= FALSE
IF FNgeticonstate(proc%,6) A$+=" -gamma"+FNlocale_convert($p%(1),decimal_point$,".")
IF FNgeticonstate(proc%,7) A$+=" -sharpen"+$p%(2)
IF FNgeticonstate(proc%,11) A$+=" -smooth"+$p%(3)
ENDPROC
:
......@@ -1357,32 +1356,25 @@ DEF PROCshowscaletofit
WHEN ASC "S"
IF VAL MID$($admode%,5)>VAL MID$($admode%,8) x=6 ELSE x=0
IF VAL MID$($admode%,2)>16 x+=5 ELSE x+=4
SYS &35,-1,11 TO ,,tofitx
SYS &35,-1,12 TO ,,tofity
SYS &35,-1,11 TO ,,tofitx%
SYS &35,-1,12 TO ,,tofity%
WHEN ASC "J"
SYS &35,-1,11 TO ,,tofitx
SYS &35,-1,12 TO ,,tofity
REM IFVALMID$($admode%,5)=8 x=3 ELSE x=5
x = 12
REM So no radio button is selected.
SYS &35,-1,11 TO ,,tofitx%
SYS &35,-1,12 TO ,,tofity%
x = 12 : REM So no radio button is selected.
OTHERWISE
REM IF FNgeticonstate(output%,24) THEN
REM SYS&35,m,11 TO,,tofitx:SYS&35,m,12 TO,,tofity
REM x = 13: REM So no radio button is selected.
REM ELSE
m=VAL $admode%
SYS &35,m,11 TO ,,tofitx
SYS &35,m,12 TO ,,tofity
SYS &35,m,11 TO ,,tofitx%
SYS &35,m,12 TO ,,tofity%
SYS &35,m,4 TO ,,x
SYS &35,m,5 TO ,,y
IF y>x x=6 ELSE x=0
SYS &35,m,9 TO ,,y
x+=y
REM ENDIF
ENDCASE
tofitx+=1
tofity+=1
$adscale%=FNmsg2("ScaleFill",STR$tofitx,STR$tofity)
tofitx%+=1
tofity%+=1
$adscale%=FNmsg2("ScaleFill",STR$tofitx%,STR$tofity%)
q%!12=1<<21
!q%=output%
FOR I%=0 TO 11
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment