Commit a5eb5af3 authored by ROOL's avatar ROOL 🤖

Add PNG output option

Detail:
  The front end adds a new 'PNG output' menu, taking its cues from the Sprite output menu, minus those options that don't make sense for Portable Network Graphics.
  Internally, the image is processed as though a sprite (this is needed because the output window is rendered by the OS and the OS has no built in PNG support) then converted to PNG on the fly during saving.
  The choices file is extended to save/recall the output window settings as appropriate.
Admin:
  Submission for PNG bounty.
parent 8684555c
......@@ -29,6 +29,17 @@ Parameters
IRLAM output as Irlam Instruments 24-bit
JPEG[MONO]<n> output as JPEG (JFIF); <n> sets the quality
of the output image in the range 0 to 100
PNGMONO[1|2|4|8][c|d|t|r],<n>[i] output as 1/2/4/8bpp PNG
with the processing suffix per sprite handling,
compressed to level <n> in the range 0 to 9,
optionally interlaced
PNG8[d|t|r],<n>[i] output as 8bpp colour PNG
with the processing suffix per sprite handling,
compressed to level <n> in the range 0 to 9,
optionally interlaced
PNG24,<n>[i] output as true colour PNG,
compressed to level <n> in the range 0 to 9,
optionally interlaced
p1 output as pbm (black & white), ASCII encoded
p2 output as pgm (grey), ASCII encoded
p3 output as ppm (colour), ASCII encoded
......
......@@ -223,13 +223,34 @@ and set up the output options:
Colour gives an image in colour.
Monochrome produces a monochrome image.
Monochrome gives an image in shades of grey.
Quality can take any value from 0 to 100 and is passed to the JPEG
compression code. The default value is 75, but you can change this using
Save choices. The default value gives the best compromise between quality
and compression.
PNG Output options
··················
To output an image in PNG format, choose PNG Output from the icon bar menu
and set up the output options:
Colour gives an image in colour.
Monochrome gives an image in shades of grey.
Compression is set with the adjuster arrows and can take any value
from 0 to 9. the value 0 is least compression, while 9 is best compression
but takes longer. The default value is a compromise between size and speed.
Interlaced PNG files will deliver a low resolution image quickly when sent
over a network, with more detail arriving once more of the file is received.
Colours: The two rows of 2, 4, 16, 256 and 16M buttons set the number of
colours in the output image.
For monochrome output the 2, 4, 16 and 256 buttons set 2, 4, 8 and 16 greys
respectively, and you cannot use the 16M button.
Reprocess
---------
This option reprocesses the file according to any new options you may have
......
......@@ -76,6 +76,8 @@ Irlam Instruments 24-bit
JPEG 'JFIF' files
Portable Bit Map (pbm) ASCII and binary encoded formats
ChangeFSI packed portable bitmaps
Portable network graphics 1, 2, 4, 8 bits per pixel with palette,
or 24 bits per pixel true colour, optionally interlaced
Details of formats
......
......@@ -12,6 +12,7 @@ Iscale:Scaling
Iproc:Processing
Ijpg:JPEG output
Ispr:Sprite output
Ipng:PNG output
Ifast:Fast
Ichoice:Save choices
Iquit:Quit
......@@ -91,14 +92,25 @@ Himnu1:\Rset the scaling factors.
Himnu2:\Rset extra image processing steps.
Himnu3:\Schoose sprite output.|M\Rset the output sprite type.
Himnu4:\Schoose JPEG output.|M\Rset the output JPEG type.
Himnu5/Hpmnu5:\Sredo this image with the selected options.
Himnu5g:\Gno image has been processed yet.
Himnu6:\Sswitch to a low video mode while calculating.
Himnu6g:\Gthe computer is already configured to be fast.
Himnu7:\Ssave the current setup as the default.
Himnu8:\Squit ChangeFSI.
Himnu5:\Schoose PNG output.|M\Rset the output PNG type.
Himnu6/Hpmnu5:\Sredo this image with the selected options.
Himnu6g:\Gno image has been processed yet.
Himnu7:\Sswitch to a low video mode while calculating.
Himnu7g:\Gthe computer is already configured to be fast.
Himnu8:\Ssave the current setup as the default.
Himnu9:\Squit ChangeFSI.
Hpmnu0:\Rsee information about the output image.
Hpmnu1:\Rsee information about the input image.
Hpmnu2:\Rsee information about the range used.
Hpmnu3:\Rset the zoom factors.
Hpmnu4:\Rsave this image to disc.
Hpng15:\Screate colour PNGs.
Hpng11:\Screate greyscale sprites.
Hpng8:\Screate a PNG using one of ChangeFSI's special colour matching options.
Hpng9:Choose from one of four colour matching options, depending on the output colours selected.|Mc: 2 or 4 colours|Md: 2, 16 or 256 colours|Mt: 2, 16 or 256 colours|Mr: 4, 16 or 256 colours
Hpng17:This is the compression level between 0 and 9.|M0 is fastest and uncompressed (larger output file).|M9 is slowest and most compressed (smaller output file).
Hpng19:\Sincrease the compression level.
Hpng18:\Sreduce the compression level.
Hpng10:\Stoggle production of interlaced images.
Hpng2/Hpng3/Hpng4/Hpng5/Hpng6:\Screate a PNG with the given number of colours.
Hpng?/Hpng??:This \w sets the output PNG type.
No preview for this file type
No preview for this file type
......@@ -87,6 +87,11 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
bright%=15
lock%= FALSE
rwt=.299 : gwt=.587 : bwt=.114 : REM CIE Y weightings for R, G, B
REM Default PNG output settings
pngparamcomp%=5
pngparamint%=0
pngcreate%=FALSE
pngmono%=FALSE
IF ARG%<3 THEN
PRINT "ChangeFSI interactive input (read CmdBasUse for command line details)"
INPUT "Source file: "s$,"Destination file: "f$,"Output mode: "m$
......@@ -175,6 +180,69 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
IF worklimit%=0 THEN flex%= FALSE ELSE flex%= TRUE :nextlocation%=worklimit%
ENDIF
pnm$=FNuc(m$)
IF LEFT$(pnm$,3)="PNG" THEN
IF LEFT$(pnm$,7)="PNGMONO" THEN
pngmono%=TRUE
pngsuffix$=MID$(pnm$,8)
ELSE
pngmono%=FALSE
pngsuffix$=MID$(pnm$,4)
ENDIF
IF LEFT$(pngsuffix$,2)="24" OR LEFT$(pnm$,4)="PNG," THEN
IF pngmono% THEN ERROR 42,"PNGMONO24 is an invalid output format"
pnm$="S32,90,90"
IF INSTR(pngsuffix$,",") pngsuffix$=MID$(pngsuffix$,INSTR(pngsuffix$,",")+1)
IF LEN(pngsuffix$)>0 THEN
pngparamcomp%=VALpngsuffix$
IF pngparamcomp%<0 pngparamcomp%=0
IF pngparamcomp%>9 pngparamcomp%=9
IF RIGHT$(pngsuffix$,1)="I" pngparamint%=1
ENDIF
ELSE
CASE LEFT$(pngsuffix$,1) OF
WHEN "": IF pngmono% pnm$="28" ELSE pnm$="S32,90,90"
WHEN "1": pnm$="25":pngsuffix$=MID$(pngsuffix$,2)
WHEN "2": pnm$="26":pngsuffix$=MID$(pngsuffix$,2)
WHEN "4": pnm$="27":pngsuffix$=MID$(pngsuffix$,2)
WHEN "8": pnm$="28":pngsuffix$=MID$(pngsuffix$,2)
WHEN "C","D","T","R",",": REM these are OK and processed later
OTHERWISE: ERROR 42,"The requested PNG bit depth is not supported"
ENDCASE
IF pngmono% THEN
CASE LEFT$(pngsuffix$,1) OF
WHEN "C":
IF pnm$="25" pnm$="25C":REM 1bpp only for mono
pngsuffix$=MID$(pngsuffix$,2)
WHEN "D":
IF pnm$<>"27" pnm$+="D":REM not valid option for mono 4bpp
pngsuffix$=MID$(pngsuffix$,2)
WHEN "T":
IF pnm$<>"28" pnm$+="T":REM not valid option for mono 8bpp
pngsuffix$=MID$(pngsuffix$,2)
WHEN "R":
REM not valid option for mono at all
pngsuffix$=MID$(pngsuffix$,2)
OTHERWISE:
REM no suffix, so make sure it's mono for 8bpp
IF pnm$="28" pnm$="28D"
ENDCASE
ELSE
IF INSTR("CDTR",LEFT$(pngsuffix$,1))>0 THEN
pnm$+=LEFT$(pngsuffix$,1)
pngsuffix$=MID$(pngsuffix$,2)
ENDIF
ENDIF
IF LEN(pngsuffix$)>0 THEN
IF LEFT$(pngsuffix$,1)<>"," THEN ERROR 42,"The requested PNG format was not recognised"
pngparamcomp%=VALMID$(pngsuffix$,2)
IF pngparamcomp%<0 pngparamcomp%=0
IF pngparamcomp%>9 pngparamcomp%=9
IF RIGHT$(pngsuffix$,1)="I" pngparamint%=1
ENDIF
ENDIF
pngcreate%=TRUE
m$=pnm$
ENDIF
CASE LEFT$(pnm$+",",3) OF
WHEN "AIM"
m=-1
......@@ -7607,7 +7675,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
ENDIF
ENDIF
LOCAL ERROR
ON ERROR LOCAL :RESTORE ERROR :PROCSave:ERROR ERR,REPORT$+" (internal number "+ STR$ERL+")":REM Error Return
ON ERROR LOCAL :RESTORE ERROR :PROCSave(TRUE):ERROR ERR,REPORT$+" (internal number "+ STR$ERL+")":REM Error Return
REM SYS"Hourglass_LEDs",3
ysamp%=1
nl%()=0
......@@ -7982,7 +8050,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
ENDIF
ENDIF
cputime%=TIME-cputime%
PROCSave
PROCSave(FALSE)
=0
REM Success!
:
......@@ -8218,8 +8286,19 @@ DEF PROCclose
ENDPROC
:
REM
DEF PROCSave
DEF PROCSave(fail%)
PROCclose
IF pngcreate% THEN
IF spritearea%=-1 AND oksave% THEN
IF o% CLOSE#o%
IF FNcreatePNG(f$)
IF o% PROCremovearea:o%=0
ELSE
IF NOT fail% pngsize%=FNcreatePNG("")
ENDIF
SYS"Hourglass_Off"
ENDPROC
ENDIF
CASE m OF
WHEN -1
IF spritearea%=-1 AND oksave% THEN
......@@ -9501,3 +9580,131 @@ DEF PROCsubtask(a$)
CALL Shell_Call
ENDIF
ENDPROC
:
REM
DEF FNcreatePNG(f$)
REM PNG needs support modules in order to work
REM Zlib prior to 0.03 does not have enough functionality for CompressPNG
SYS "XOS_CLI","RMEnsure ZLib 0.03 RMLoad System:Modules.ZLib"
OSCLI "RMEnsure ZLib 0.03 ERROR ChangeFSI requires the ZLib module to perform this operation"
SYS "XOS_CLI","RMEnsure CompressPNG 0 RMLoad System:Modules.CompressPNG"
OSCLI "RMEnsure CompressPNG 0 ERROR ChangeFSI requires the CompressPNG module to perform this operation"
REM either create a PNG or determine its filesize for later
LOCAL pngparam%,pngtag%,spr%,sprw%,sprh%,sprmode%,pngdepth%,pngpalette%,Y%,lineptr%,X%,areabase%
LOCAL dest%,linebuffer%,rowstride%,pixmask%,offset%
IF ram% areabase%=ram% ELSE areabase%=base%
spr%=areabase%+areabase%!8
SYS "OS_SpriteOp",512+40,areabase%,spr% TO ,,,sprw%,sprh%,,sprmode%
REM mode will be 25/26/27/28 for 1/2/4/8 bpp depths, or a modeword for true colour
rowstride%=(1+spr%!16)*4
CASE sprmode% OF
WHEN 25: pngdepth%=1
WHEN 26: pngdepth%=2
WHEN 27: pngdepth%=4
WHEN 28: pngdepth%=8
OTHERWISE: pngdepth%=24
ENDCASE
REM if <256 colours then mono is done as paletted, not 'true' mono without a palette
IF pngdepth%<8 pngmono%=FALSE
pngparam%=FNdim(60)
!pngparam%=sprw%:REM sprite width
pngparam%!4=sprh%:REM sprite height
pngparam%!8=90
pngparam%!12=90
IF pngmono% THEN
pngparam%!16=1<<2:REM Mono input stream
ELSE
REM if true colour, set skip alpha, else use raw input stream
IF pngdepth%=24 THEN pngparam%!16=1<<3 ELSE pngparam%!16=0
ENDIF
pngparam%!20=3:pngparam%!24=pngparamcomp%:pngparam%!28=0
pngparam%!32=4:pngparam%!36=pngparamint%:pngparam%!40=0
IF pngdepth%<24 AND NOT pngmono% THEN
REM generate a palette for this one
pngpalette%=FNdim(4*(1<<pngdepth%))
pngparam%!44=5
pngparam%!48=1<<pngdepth%
pngparam%!52=pngpalette%
pngparam%!56=0
dest%=pngpalette%
maxcol%=(1<<pngdepth%)-1
REM ChangeFSI either generates palette or not, never a mask
REM <8bpp has a palette, 8bpp might or might not
IF spr%!32>44 THEN
REM get from sprite
FOR X%=0 TO maxcol%
!(pngpalette%+4*X%)=!(spr%+44+X%*8)>>8
NEXT
ELSE
REM standard colour palette
F=255: REM intensity
CASE pngdepth% OF
WHEN 8: PROCdefpal
WHEN 4: PROCdefpal16
WHEN 2: PROCdefpal4
WHEN 1: PROCdefpal2: r%(1)=0: g%(1)=0:b%(1)=0
ENDCASE
FOR X%=0 TO maxcol%
!(pngpalette%+4*X%)=r%(X%) OR (g%(X%)<<8) OR (b%(X%)<<16)
NEXT
ENDIF
ELSE
REM no table needed - true colour or true mono PNG output
pngpalette%=0
pngparam%!44=0
ENDIF
REM if we're not doing true colour then we'll need to extract the data into a line buffer
REM 256 colour entries are OK as they are already in a handy byte stream
IF pngdepth%<8 THEN
linebuffer%=FNdim(sprw%)
pixmask%=(1<<pngdepth%)-1
ppb%=8 DIV pngdepth%
ELSE
linebuffer%=0
ENDIF
IF f$="" THEN
SYS"CompressPNG_Start",0,0,pngparam% TO pngtag%
ELSE
pngparam%!16=pngparam%!16 OR (1<<0)
SYS"CompressPNG_Start",f$,0,pngparam% TO pngtag%
ENDIF
LOCAL ERROR
ON ERROR LOCAL:RESTORE ERROR:SYS"XCompressPNG_Finish",pngtag%:ERROR ERR,REPORT$+" at line "+STR$ERL
REM sign the work
SYS"CompressPNG_Comment",pngtag%,"Author","RISC OS ChangeFSI"
REM run the conversion
lineptr%=spr%+spr%!32
FORY%=0 TO sprh%-1
SYS"Hourglass_Percentage",(Y%*100) DIV sprh%
IF linebuffer% THEN
REM extract the line to a byte string of pixels
FOR X%=0 TO sprw%-1
offset%=lineptr%+(X% DIV ppb%)
shift=(X% MOD ppb%)*pngdepth%
?(linebuffer%+X%)=(?offset% >> shift) AND pixmask%
NEXT
SYS"CompressPNG_WriteLine",pngtag%,linebuffer%
ELSE
SYS"CompressPNG_WriteLine",pngtag%,lineptr%
ENDIF
lineptr%+=rowstride%
NEXT
REM tidy up afterwards
SYS"CompressPNG_Finish",pngtag% TO ,pngsize%
=pngsize%
......@@ -76,9 +76,9 @@ IF task% THEN
SYS "Wimp_SlotSize",-1,-1 TO originalslot%
PROClocale_initialise
IF version%>=300 THEN
DIM q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 255,idata% 1023
DIM q% 255,ifactors% 15,factors% 15,pixtrans% 1023,paltemp% 1023,buffer% 267,idata% 1023
ELSE
DIM z% 1699,q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 255,idata% 2399
DIM z% 1699,q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 267,idata% 2399
eidata%=idata%+2400
ENDIF
scrap%= FALSE
......@@ -125,6 +125,7 @@ IF task% THEN
s%(2)=!(z%+88+12*32+20)
s%(3)=!(z%+88+13*32+20)
PROCdotemplate("Save")
!(z%+88+0*32+24)=1:REM force sprite area to be correct
SYS CreateW,,z% TO save%
adsave%=!(z%+88+1*32+20)
adsavesprite%=!(z%+88+0*32+20)
......@@ -148,6 +149,12 @@ IF task% THEN
PROCdotemplate("JPEGOutput")
SYS CreateW,,z% TO jpego%
adjpegq%=!(z%+88+5*32+20)
pngo%=-1
PROCdotemplate("PNGOutput")
SYS CreateW,,z% TO pngo%
pngspecial%=!(z%+88+9*32+20)
pngcomp%=!(z%+88+17*32+20)
pngsize%=-1
PROCdotemplate("Pic")
SYS CreateW,,z% TO pic%
adtitle%=z%!72
......@@ -181,14 +188,34 @@ IF task% THEN
$s%(3)="4"
$adjpegq%="75"
$oldmode%=""
$pngcomp%="5"
$pngspecial%=""
pngstate%=%1000000001000000
ELSE
INPUT#A%,fast%,dest%,statescale%,stateproc%,stateoutput%,statejpeg%,$adjpegq%,$oldmode%
INPUT#A%,$p%(0),$p%(1),$p%(2),$p%(3),$admode%,$adspcl%
$p%(1)=FNlocale_convert($p%(1),".",decimal_point$)
INPUT#A%,$s%(0),$s%(1),$s%(2),$s%(3)
IF NOT EOF#A% THEN
REM If there's more data, assume it relates to the PNG status
INPUT#A%,$pngcomp%,$pngspecial%,pngstate%
ELSE
REM Old choices, use defaults
$pngcomp%="5"
$pngspecial%=""
pngstate%=%1000000001000000
ENDIF
CLOSE#A%
ENDIF
q%!12=1<<21
REM PNG choices display buttons
!q%=pngo%
q%!4=10
FOR J%=2 TO 15
q%!4=J%
q%!8=((pngstate%>>J%) AND 1)<<21
SYS SetI,,q%
NEXT
!q%=scalew%
FOR I%=0 TO 9
IF statescale%>>I% AND 1 q%!8=1<<21 ELSE q%!8=0
......@@ -228,6 +255,13 @@ IF task% THEN
SYS "XOS_ReadModeVariable",&501680B5,9 TO,,m : REM Log2bpp 64k
IF m<>4 THEN kernspt%=kernspt% AND NOT(1<<8)
REM If monochrome, fade true colours
IF (pngstate% AND (1<<11)) THEN
!q%=pngo%
q%!4=6
q%!8=1<<22
q%!12=1<<22
SYS SetI,,q%
ENDIF
!q%=output%
q%!12=1<<22
FOR I%=6 TO 9
......@@ -240,7 +274,7 @@ IF task% THEN
$z%(0)="1"
$z%(1)="1"
SYS "OS_UpdateMEMC" TO oldmemc
jpegsave%= FALSE
imgsave%= 1
ON ERROR SYS "OS_UpdateMEMC",oldmemc,&700:PROCerrorbox:SYS CrMenu,,-1 : REM close menus!
SYS Drag,,-1
IF NOT sprite% SYS "Wimp_SlotSize",originalslot%,-1
......@@ -274,12 +308,11 @@ IF task% THEN
q%!24=di%
q%!28=!q%
q%!32=q%!4
q%!36=!sar%+3
IF jpegsave% THEN
q%!40=&c85
ELSE
q%!40=&ff9
ENDIF
CASE imgsave% OF
WHEN 0:q%!40=&c85:q%!36=!sar%+3
WHEN 1:q%!40=&ff9:q%!36=!sar%+3
WHEN 2:q%!40=&b60:q%!36=pngsize%
ENDCASE
temp$=FNZS(adsave%)
foo%=INSTR(temp$,".")
WHILE foo%
......@@ -379,11 +412,12 @@ DEF PROCreceive(q%)
scrap%=q%!8
ENDIF
WHEN 2
IF jpegsave% THEN
SYS "OS_File",10,FNZS(q%+44),&c85,,sar%,sar%+jpegsize%
ELSE
SYS &2E,&10C,sar%,FNZS(q%+44)
ENDIF
CASE imgsave% OF
WHEN 0:SYS "OS_File",10,FNZS(q%+44),&c85,,sar%,sar%+jpegsize%
WHEN 1:SYS &2E,&10C,sar%,FNZS(q%+44)
WHEN 2:base%=sar%
IF FNcreatePNG(FNZS(q%+44))
ENDCASE
$adsave%=FNZS(q%+44)
q%!12=q%!8
q%!16=3
......@@ -445,6 +479,8 @@ DEF PROCgethelp(w%,i%)
$(q%+20)=FNmsg0("Hzoom"+STR$(i%))
WHENjpego%
$(q%+20)=FNmsg0("Hjpeg"+STR$(i%))
WHENpngo%
$(q%+20)=FNmsg0("Hpng"+STR$(i%))
WHENpic%
$(q%+20)=FNmsg0("Hpic"+STR$(i%))
WHEN-2
......@@ -456,8 +492,8 @@ DEF PROCgethelp(w%,i%)
IF lastm%=101 THEN
REM The iconbar menu
LOCAL grey$
IF (q%!20=6) AND vram% THEN grey$="g"
IF (q%!20=5) AND (F$="" OR F$="SpriteFile" OR F$="JPEGImage") THEN grey$="g"
IF (q%!20=7) AND vram% THEN grey$="g"
IF (q%!20=6) AND (F$="" OR F$="SpriteFile" OR F$="JPEGImage") THEN grey$="g"
$(q%+20)=FNmsg0("Himnu"+STR$(q%!20)+grey$)
ELSE
IF lastm%=pic% THEN
......@@ -481,31 +517,47 @@ DEF PROCcallFSI
IF FNcheckvalues <> 0 THEN ENDPROC
A$=FNdeducemode
A%=47
jpegsave%= FALSE
IF dest%=0 THEN
jpegsave%= TRUE
A$="JPEG"
IF FNgeticonstate(jpego%,2) A$="JPEGMONO"
A$+=$adjpegq%
ELSE
IF FNgeticonstate(output%,15) THEN
A$+=$adspcl%
ELSE
IF FNgeticonstate(output%,16) THEN
IF FNgeticonstate(output%,3) AND FNgeticonstate(output%,11) A$+="R"
imgsave%= dest%
CASE dest% OF
WHEN 0
A$="JPEG"
IF FNgeticonstate(jpego%,2) A$="JPEGMONO"
A$+=$adjpegq%
WHEN 1
IF FNgeticonstate(output%,15) THEN
A$+=$adspcl%
ELSE
SYS 53,VAL A$,3 TO ,,A%
IF A%=63 THEN
IF FNgeticonstate(output%,5) THEN
IF FNgeticonstate(output%,11) A$="27t":REM Square 256
IF FNgeticonstate(output%,10) A$="12t":REM Rect 256
ENDIF
IF FNgeticonstate(output%,16) THEN
IF FNgeticonstate(output%,3) AND FNgeticonstate(output%,11) A$+="R"
ELSE
IF A%=255 A$+="d"
SYS 53,VAL A$,3 TO ,,A%
IF A%=63 THEN
IF FNgeticonstate(output%,5) THEN
IF FNgeticonstate(output%,11) A$="27t":REM Square 256
IF FNgeticonstate(output%,10) A$="12t":REM Rect 256
ENDIF
ELSE
IF A%=255 A$+="d"
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
WHEN 2
REM basic PNG flavour
pngmono%=FNgeticonstate(pngo%,11)
IF pngmono% A$="PNGMONO" ELSE A$="PNG"
REM colour/bit depth
IF FNgeticonstate(pngo%,2) A$+="1"
IF FNgeticonstate(pngo%,3) A$+="2"
IF FNgeticonstate(pngo%,4) A$+="4"
IF FNgeticonstate(pngo%,5) A$+="8"
IF FNgeticonstate(pngo%,6) A$+="24"
REM special options
IF FNgeticonstate(pngo%,8) A$+=$pngspecial%
REM compression
A$+=","+$pngcomp%
REM interlace
IF FNgeticonstate(pngo%,10) A$+="i"
ENDCASE
A$="garbage "+F$+" <ChangeFSI$Dir>.Foo "+A$
PROCChangeFSISuffix
info$=""
......@@ -522,35 +574,58 @@ DEF PROCcallFSI
IF A%<2 AND sar%<>0 THEN
$adsx%= STR$xsp%
$adsy%= STR$ysp%
IF jpegsave% THEN
$adsm%="JPEG"
$adsname%="JPEG"
$adsbytes%= STR$jpegsize%
x=xsp%*2
y=ysp%*2
SYS &35,-1,4 TO ,,nx
SYS &35,-1,5 TO ,,ny
!ifactors%=1
ifactors%!4=1
ifactors%!8=nx
ifactors%!12=ny
$adsavesprite%="file_c85"
IF LEFT$(F$,7)="<Wimp$S" F$="JPEGImage"
ELSE
SYS &2002E,&10d,sar%,pixtrans%,255,1
n$=FNZS(pixtrans%)
SYS &2002E,&128,sar%,n$ TO ,,,x,y,,m
IF (m<256 AND SGN(m)<>-1) THEN $adsm%=STR$m ELSE $adsm%="&"+STR$~m
$adsname%=n$
$adsbytes%= STR$sar%!12
SYS &35,m,4 TO ,,nx
x=x<<nx
SYS &35,m,5 TO ,,ny
y=y<<ny
PROCgetmodeinfo
$adsavesprite%="file_ff9"
IF LEFT$(F$,7)="<Wimp$S" F$="SpriteFile"
ENDIF
CASE imgsave% OF
WHEN 0
$adsm%="JPEG"
$adsname%="JPEG"
$adsbytes%= STR$ jpegsize%
x=xsp%*2
y=ysp%*2
SYS &35,-1,4 TO ,,nx
SYS &35,-1,5 TO ,,ny
!ifactors%=1
ifactors%!4=1
ifactors%!8=nx
ifactors%!12=ny
$adsavesprite%="file_c85"
IF LEFT$(F$,7)="<Wimp$S" F$="JPEGImage"
WHEN 1
SYS &2002E,&10d,sar%,pixtrans%,255,1
n$=FNZS(pixtrans%)
SYS &2002E,&128,sar%,n$ TO ,,,x,y,,m
IF (m<256 AND SGN(m)<>-1) THEN$adsm%=STR$ m ELSE$adsm%="&"+STR$~m
$adsname%=n$
$adsbytes%= STR$ sar%!12
SYS &35,m,4 TO ,,nx
x=x<<nx
SYS &35,m,5 TO ,,ny
y=y<<ny
PROCgetmodeinfo
$adsavesprite%="file_ff9"
IF LEFT$(F$,7)="<Wimp$S" F$="SpriteFile"
WHEN 2
IF pngmono% THEN
$adsname%="PNGMONO"
$adsm%="Greyscale"
ELSE
$adsm%="Colour"
$adsname%="PNG"
ENDIF
$adsbytes%=STR$ pngsize%
x=xsp%*2
y=ysp%*2
SYS &35,-1,4 TO ,,nx
SYS &35,-1,5 TO ,,ny
!ifactors%=1
ifactors%!4=1
ifactors%!8=nx
ifactors%!12=ny
$adsavesprite%="file_b60"
IF LEFT$(F$,7)="<Wimp$S" F$="PNGImage"
SYS &2002E,&10d,sar%,pixtrans%,255,1
n$=FNZS(pixtrans%)
PROCgetmodeinfo
ENDCASE
!q%=save%
q%!4=0
q%!8=0
......@@ -745,23 +820,28 @@ DEF PROCsavesprite
ENDPROC
ENDIF
ENDIF
IF jpegsave% THEN
SYS "OS_File",10,$adsave%,&c85,,sar%,sar%+jpegsize%
ELSE
SYS &2E,&10C,sar%,$adsave%
ENDIF
CASE imgsave% OF
WHEN 0:SYS "OS_File",10,$adsave%,&c85,,sar%,sar%+jpegsize%
WHEN 1:SYS &2E,&10C,sar%,$adsave%
WHEN 2:base%=sar%:IF FNcreatePNG($adsave%)
ENDCASE
SYS CrMenu,,-1
ENDPROC
:
REM
DEF PROCcheckmouse(mousex%,mousey%,b%,handle%,icon%,ob%)
LOCAL moved%,sqr$,imenu$,pmenu$
LOCAL moved%,sqr$,imenu$,pmenu$,spropt%,jpegopt%,pngopt%
jpegopt%=(1<<dest%) AND 1
spropt%=dest% AND 1
pngopt%=(dest%>>1) AND 1
REM Picture menu structure
pmenu$= FNmsg0("Pimg")+">sinfo%,"+FNmsg0("Psrc")+">srcinfo%,"+FNmsg0("Prange")+">raninfo%,"
pmenu$=pmenu$+FNmsg0("Pzoom")+">zoom%,"+FNmsg0("Psave")+">save%,"+FNmsg0("PIredo")