Commit d1156009 authored by Robert Sprowson's avatar Robert Sprowson

Add support for 32bpp Sun raster files

Fix support for 24bpp RLE compressed Sun raster files

The former is merely 24b data on 32b boundaries (the format doesn't support transparency), so this need not be rejected by ChangeFSI.
The latter caused a data abort because the decoder assumed all RLE data could be handled by FN1100 but in the 24bpp case there's 3 times more data than expected so you fall off the end of memory.
Test image for type 3 Sun rasters produced as these seem hard to find.
Now correctly decodes all the sample images at
  http://samples.libav.org/image-samples/sunrast/
Docs updated.

Version 1.48. Tagged as 'ChangeFSI-1_48'
parent 1a4fa8ca
......@@ -421,16 +421,20 @@ Used for some VGA demos, the format provides an uncompressed 320 by 200 by
Sun 'pixrect' raster files
--------------------------
Used under SunOS and also under X11. Commonly 1 or 8 bits per pixel, but up
to 24 bits per pixel can be found (see the Sun NeWS release tape!).
Used under SunOS and also under X11. Eight header fields precede an optional
palette (not for 24 and 32bpp, which are true colour) followed by image data.
Possible to encounter 1, 4, 8, 24, 32 bits per pixel variants.
Recognised by &956AA659 at the start of the file.
No resolution specified; equal to mode 27 assumed.
Sun didn't specify the pixel ordering of 24 bit per pixel images: many
Can optionally be RLE compressed.
Sun didn't specify the pixel ordering of 24 & 32 bit per pixel images: many
assume RGB when it was actually BGR. Change byte &17 in the Sun rasterfile
between 1 and 3 if you have a problem.
between 1 and 3 if you have a problem, type 2 (RLE compressed) always
assumes BGR ordering.
GEM IMG images
--------------
......@@ -637,7 +641,7 @@ run length coded by the Mac's "PackBits" algorithm (repeated bytes).
Size of pixel specified.
Only 3 pictures read - since the format is very complicated (e.g. the size
of things change if >250 rows in the picture!) this is no guarentee that
of things change if >250 rows in the picture!) this is no guarantee that
anything else will be right.
RT 24-bit run length coded IMAGE files
......
/* (1.47)
/* (1.48)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.47
#define Module_MajorVersion_CMHG 1.48
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 04 Apr 2014
#define Module_Date_CMHG 02 Aug 2014
#define Module_MajorVersion "1.47"
#define Module_Version 147
#define Module_MajorVersion "1.48"
#define Module_Version 148
#define Module_MinorVersion ""
#define Module_Date "04 Apr 2014"
#define Module_Date "02 Aug 2014"
#define Module_ApplicationDate "04-Apr-14"
#define Module_ApplicationDate "02-Aug-14"
#define Module_ComponentName "ChangeFSI"
#define Module_ComponentPath "mixed/RiscOS/Sources/Apps/ChangeFSI"
#define Module_FullVersion "1.47"
#define Module_HelpVersion "1.47 (04 Apr 2014)"
#define Module_LibraryVersionInfo "1:47"
#define Module_FullVersion "1.48"
#define Module_HelpVersion "1.48 (02 Aug 2014)"
#define Module_LibraryVersionInfo "1:48"
......@@ -2487,21 +2487,19 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
info$="ProArtisan image, 640 by 256 pixels, 8 bits per pixel"
WHEN 1100
REM Sun pixrect
quant%=1
PTR#c%=4
sx%=FNbeW
sy%=FNbeW
input=FNbeW
quant%=input
bigendianbits= TRUE
S%=FNbeW
S%=FNbeW
REM 0=RT_OLD,1=RT_STD(BGR),2=RT_BYTE_ENC,3=RT_FORMAT_RGB
S%=FNbeW : REM image length in bytes (ignored)
S%=FNbeW : REM 0=RT_OLD,1=RT_STD(BGR),2=RT_BYTE_ENC,3=RT_FORMAT_RGB
C%=FNbeW : REM maptype 0=RMT_NONE,1=RMT_EQUAL_RGB,2=RMT_RAW
D%=FNbeW : REM maplength in bytes
cache%= TRUE
IF S%=2 cachebytes%= TRUE :info$="Byte Encoded " ELSE info$="":r$="FN8"
C%=FNbeW
REM maptype 0=RMT_NONE,1=RMT_EQUAL_RGB,2=RMT_RAW
D%=FNbeW
REM maplength in bytes
IF S%=2 cachebytes%= TRUE :info$="Byte encoded " ELSE info$="":r$="FN8"
IF S%>3 OR C%>2 ERROR 42,"Can't do this type of Sun raster"
CASE C% OF
WHEN 1,2
FOR I%=0 TO D%/3-1
......@@ -2521,7 +2519,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
b%(0)=F
WHEN 4,8
PROCnopal
WHEN 24
WHEN 24,32
PROCnopal
ENDCASE
ENDCASE
......@@ -2532,21 +2530,20 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
rowbytes%=(sx%+3>>2)<<1
WHEN 8
rowbytes%=(sx%+1>>1)<<1
WHEN 24
rowbytes%=(3*sx%+1>>1)<<1
r$="FN24"
rbo%=0
WHEN 24,32
rbo%=2
gbo%=1
bbo%=2
step24=3
IF S%=1 bbo%=0:rbo%=2
OTHERWISE
ERROR 42,"Can't do this Sun pixrect"
bbo%=0
IF S%=3 SWAP bbo%,rbo% : REM RGB not default BGR
IF S%=2 r$="FN1124" ELSE r$="FN24" : REM RLE not raw
step24=quant% DIV 8
rowbytes%=(step24*sx%+1>>1)<<1
input=24
ENDCASE
st%=D%+&20
rep%=0
IF cachebytes% plbuff%=FNdim(rowbytes%):plbytes%=rowbytes%
info$+="Sun image, "+ STR$sx%+" by "+ STR$sy%+" pixels, "+FNbits(input)
info$+="Sun raster image, "+ STR$sx%+" by "+ STR$sy%+" pixels, "+FNbits(quant%)
WHEN 1200
REM unknown TimeStep satellite format
quant%=8
......@@ -8068,7 +8065,7 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
FNcpsr_from_r(2)
MOV PC,R14
]
WHEN "FN1900","FN1100","FN400"
WHEN "FN1900","FN1124","FN1100","FN400"
[ OPT Z%(Z)
REM CALL readline%,limitbytes%,repeat%,colour%,address%
.readline%
......@@ -8143,8 +8140,8 @@ DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%
TEQ R2,R6
BNE rle
.rlexit
STR R0,[R3]
STR R5,[R4]
STR R0,[R3] REM RLE continuation colour
STR R5,[R4] REM RLE continuation count
LDMFD SP !,{R5,R14}
FNcpsr_from_r(5)
MOV PC,R14
......@@ -10184,6 +10181,15 @@ DEF FN1100(z%())
CALL mappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff%
= TRUE
:
REM 24 (and 32bpp) packed RLE'd: SunRaster
DEF FN1124(z%())
CALL readline%,plbytes%,rep%,pix%,plbuff%
rb%=plbuff%+rbo%
gb%=plbuff%+gbo%
bb%=plbuff%+bbo%
CALL mappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb%
= TRUE
:
REM 1-8bpp planar RLE'd: IMG
DEF FN1400(z%())
IF vrep% THEN
......
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