Commit e5100890 authored by Robert Sprowson's avatar Robert Sprowson

Switch to using common JPEG code in RISC_OSLib.

Allows better sharing when !Draw is also in ROM.
Fix long (long) standing bug of not being able to drag JPEGs into !Paint using the RAM transfer protocol - some dubious pointer arithmetic meant the wrong address of JPEG data was used and so gave an error.
The 3 paths that result in a JPEG->Sprite conversion now share code too.
Remove local definition of FileType_JPEG, use that in the exports.

Version 2.05. Tagged as 'Paint-2_05'
parent a42c3c38
...@@ -108,11 +108,11 @@ DFILES = \ ...@@ -108,11 +108,11 @@ DFILES = \
debug.${APP}.Templates debug.${APP}.Templates
OBJS = o.colours o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow \ OBJS = o.colours o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow \
o.jpeg o.AltRename o.PaintLib o.AltRename o.PaintLib
OBJSZ = oz.colours oz.main oz.menus oz.psprite oz.sprwindow\ OBJSZ = oz.colours oz.main oz.menus oz.psprite oz.sprwindow\
oz.tools oz.toolwindow o.jpeg oz.AltRename oz.PaintLib oz.tools oz.toolwindow oz.AltRename oz.PaintLib
OBJSD = od.colours od.ftrace od.guard od.main od.menus\ OBJSD = od.colours od.ftrace od.guard od.main od.menus\
od.psprite od.sprwindow od.tools od.toolwindow o.jpeg o.m\ od.psprite od.sprwindow od.tools od.toolwindow o.m\
od.AltRename od.PaintLib od.AltRename od.PaintLib
ASMS = s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow ASMS = s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow
INCS = i.colours i.main i.menus i.psprite i.sprwindow i.tools i.toolwindow INCS = i.colours i.main i.menus i.psprite i.sprwindow i.tools i.toolwindow
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "2.04" Module_MajorVersion SETS "2.05"
Module_Version SETA 204 Module_Version SETA 205
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "07 Dec 2010" Module_Date SETS "07 Dec 2010"
Module_ApplicationDate SETS "07-Dec-10" Module_ApplicationDate SETS "07-Dec-10"
Module_ComponentName SETS "Paint" Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint" Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.04" Module_FullVersion SETS "2.05"
Module_HelpVersion SETS "2.04 (07 Dec 2010)" Module_HelpVersion SETS "2.05 (07 Dec 2010)"
END END
/* (2.04) /* (2.05)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 2.04 #define Module_MajorVersion_CMHG 2.05
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 07 Dec 2010 #define Module_Date_CMHG 07 Dec 2010
#define Module_MajorVersion "2.04" #define Module_MajorVersion "2.05"
#define Module_Version 204 #define Module_Version 205
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "07 Dec 2010" #define Module_Date "07 Dec 2010"
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
#define Module_ComponentName "Paint" #define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint" #define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.04" #define Module_FullVersion "2.05"
#define Module_HelpVersion "2.04 (07 Dec 2010)" #define Module_HelpVersion "2.05 (07 Dec 2010)"
#define Module_LibraryVersionInfo "2:4" #define Module_LibraryVersionInfo "2:5"
;ObjAsm file for JPEG
;written by DefMod (Aug 16 1994) on Tue Sep 20 15:06:43 1994
;Tweaked for 32-bit by KBracey on Sat Nov 27 1999
R0 RN 0
R1 RN 1
R2 RN 2
R3 RN 3
R4 RN 4
R5 RN 5
R6 RN 6
R7 RN 7
R8 RN 8
R9 RN 9
A1 RN 0
A2 RN 1
A3 RN 2
A4 RN 3
V1 RN 4
V2 RN 5
V3 RN 6
V4 RN 7
V5 RN 8
V6 RN 9
R RN 0
SL RN 10
FP RN 11
IP RN 12
SP RN 13
LR RN 14
PC RN 15
GET Hdr:ListOpts
GET Hdr:APCS.<APCS>
EXPORT xjpeginfo_dimensions
EXPORT jpeginfo_dimensions
EXPORT xjpegfileinfo_dimensions
EXPORT jpegfileinfo_dimensions
EXPORT xjpeg_plot_scaled
EXPORT jpeg_plot_scaled
EXPORT xjpeg_plot_file_scaled
EXPORT jpeg_plot_file_scaled
EXPORT xjpeg_plot_transformed
EXPORT jpeg_plot_transformed
EXPORT xjpeg_plot_file_transformed
EXPORT jpeg_plot_file_transformed
AREA |SWI$$Code|, CODE, READONLY
xjpeginfo_dimensions ROUT
MOV IP, LR
STMFD SP!, {A3, A4, V1, V2, V3}
MOV R2, A2
MOV R1, A1
MOV R0, #&1
SWI &69980
BVS %99
LDR LR, [SP, #0]
TEQ LR, #0
STRNE R0, [LR]
LDR LR, [SP, #4]
TEQ LR, #0
STRNE R2, [LR]
LDR LR, [SP, #20]
TEQ LR, #0
STRNE R3, [LR]
LDR LR, [SP, #24]
TEQ LR, #0
STRNE R4, [LR]
LDR LR, [SP, #28]
TEQ LR, #0
STRNE R5, [LR]
MOV R, #0
99 ADD SP, SP, #8
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked,,IP
jpeginfo_dimensions ROUT
STMFD SP!, {A3, A4, V1, V2, V3}
MOV R2, A2
MOV R1, A1
MOV R0, #&1
SWI &49980
LDR IP, [SP, #0]
TEQ IP, #0
STRNE R2, [IP]
LDR IP, [SP, #4]
TEQ IP, #0
STRNE R3, [IP]
LDR IP, [SP, #20]
TEQ IP, #0
STRNE R4, [IP]
LDR IP, [SP, #24]
TEQ IP, #0
STRNE R5, [IP]
ADD SP, SP, #8
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked
xjpegfileinfo_dimensions ROUT
MOV IP, LR
STMFD SP!, {A2, A3, A4, V1, V2, V3}
MOV R1, A1
MOV R0, #&1
SWI &69981
BVS %99
LDR LR, [SP, #0]
TEQ LR, #0
STRNE R0, [LR]
LDR LR, [SP, #4]
TEQ LR, #0
STRNE R2, [LR]
LDR LR, [SP, #8]
TEQ LR, #0
STRNE R3, [LR]
LDR LR, [SP, #24]
TEQ LR, #0
STRNE R4, [LR]
LDR LR, [SP, #28]
TEQ LR, #0
STRNE R5, [LR]
MOV R, #0
99 ADD SP, SP, #12
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked,,IP
jpegfileinfo_dimensions ROUT
STMFD SP!, {A2, A3, A4, V1, V2, V3}
MOV R1, A1
MOV R0, #&1
SWI &49981
LDR IP, [SP, #0]
TEQ IP, #0
STRNE R2, [IP]
LDR IP, [SP, #4]
TEQ IP, #0
STRNE R3, [IP]
LDR IP, [SP, #8]
TEQ IP, #0
STRNE R4, [IP]
LDR IP, [SP, #24]
TEQ IP, #0
STRNE R5, [IP]
ADD SP, SP, #12
LDMFD SP!, {V1, V2, V3}
Return ,LinkNotStacked
xjpeg_plot_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, V2, LR}
LDMFD IP, {R4, R5}
SWI &69982
MOVVC R, #0
Return "V1, V2"
jpeg_plot_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, V2, LR}
LDMFD IP, {R4, R5}
SWI &49982
Return "V1, V2"
xjpeg_plot_file_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, LR}
LDMFD IP, {R4}
SWI &69983
MOVVC R, #0
Return "V1"
jpeg_plot_file_scaled ROUT
MOV IP, SP
STMFD SP!, {V1, LR}
LDMFD IP, {R4}
SWI &49983
Return "V1"
xjpeg_plot_transformed ROUT
MOV IP, LR
SWI &69984
MOVVC R, #0
Return ,LinkNotStacked,,IP
jpeg_plot_transformed ROUT
SWI &49984
Return ,LinkNotStacked
xjpeg_plot_file_transformed ROUT
MOV IP, LR
SWI &69985
MOVVC R, #0
Return ,LinkNotStacked,,IP
jpeg_plot_file_transformed ROUT
SWI &49985
Return ,LinkNotStacked
END
...@@ -355,6 +355,49 @@ static int mouseB (void) ...@@ -355,6 +355,49 @@ static int mouseB (void)
return r.r[2]; return r.r[2];
} }
static sprite_header *main_make_newjpeg (sprite_area *area, int size, jpeg_info *info)
{ sprite_header *header;
int log2bpp = bbc_modevar (-1, bbc_Log2BPP);
area->size = size + sizeof (sprite_area);
area->number = 1;
area->sproff = 16;
area->freeoff = size + sizeof (sprite_area);
header = (sprite_header *)((char *)area + sizeof (sprite_area));
header->next = size;
strcpy (header->name, "!newjpeg");
header->width = ((info->width << log2bpp) - 1)/32;
header->height = info->height - 1;
header->lbit = 0;
header->rbit = (info->width << log2bpp) - 32 * header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2bpp <= 3 ? 8 << (1 << log2bpp) : 0);
header->mode = log2bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
return header;
}
static os_error *main_plot_fromjpeg (sprite_area *area, sprite_header *header, jpeg_id *jid)
{ os_error *error;
int s1, s2, s3;
/* Switch to sprite, plot the JPEG, switch back */
error = os_swix4r (OS_SpriteOp, 0x23C, area, header, 0,
NULL, &s1, &s2, &s3);
if (error != NULL) return error;
error = jpeg_put_scaled (jid, 0, 0, NULL,
jpeg_PUT_DITHER_ENABLE | jpeg_PUT_ERROR_DIFFUSED_DITHER);
if (error != NULL) return error;
return os_swix4 (OS_SpriteOp, 0x23C, s1, s2, s3);
}
static void main_icon_bboxes (main_window *window, main_sprite *sprite, wimp_box *iniconbbox, static void main_icon_bboxes (main_window *window, main_sprite *sprite, wimp_box *iniconbbox,
wimp_box *spritebbox, wimp_box *namebbox) wimp_box *spritebbox, wimp_box *namebbox)
...@@ -849,7 +892,7 @@ static int ramfetch_buffer_extender (char **buffer, int *size) ...@@ -849,7 +892,7 @@ static int ramfetch_buffer_extender (char **buffer, int *size)
static BOOL ramtransfer_file (wimp_msgdatasave *ms) static BOOL ramtransfer_file (wimp_msgdatasave *ms)
{ int size, import = -1, file_type, s1, s2, s3, sprite_size, width, height, { int size, import = -1, file_type, sprite_size,
ram_size, log2_bpp = bbc_modevar (-1, bbc_Log2BPP); ram_size, log2_bpp = bbc_modevar (-1, bbc_Log2BPP);
sprite_area *area; sprite_area *area;
sprite_header *header; sprite_header *header;
...@@ -858,7 +901,7 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms) ...@@ -858,7 +901,7 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
/*only interested in sprites*/ /*only interested in sprites*/
/*and jpeg's. J R C 27th Jun 1994*/ /*and jpeg's. J R C 27th Jun 1994*/
if (!((file_type = xferrecv_checkimport (&size)) == FileType_Sprite || if (!((file_type = xferrecv_checkimport (&size)) == FileType_Sprite ||
file_type == jpeg_FILE_TYPE)) file_type == FileType_JPEG))
{ werr (FALSE, msgs_lookup ("PntEB"), ms->leaf); { werr (FALSE, msgs_lookup ("PntEB"), ms->leaf);
return FALSE; return FALSE;
} }
...@@ -887,53 +930,42 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms) ...@@ -887,53 +930,42 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
return FALSE; return FALSE;
} }
if (file_type == jpeg_FILE_TYPE) if (file_type == FileType_JPEG)
{ /*For JPEG's, we find it convenient to read the file data into { jpeg_id jid;
|ramfetch_buffer| (since that is how ramfetch_buffer_extender () is set jpeg_info jinfo;
/*For JPEG's, we find it convenient to read the file data into
|ramfetch_buffer| (since that is how ramfetch_buffer_extender() is set
up), then read the consequent sprite size, malloc that much space, up), then read the consequent sprite size, malloc that much space,
paint the sprite and copy it back into |ramfetch_buffer|.*/ paint the sprite and copy it back into |ramfetch_buffer|.*/
ram_size = flex_size ((flex_ptr) &ramfetch_buffer); ram_size = flex_size ((flex_ptr) &ramfetch_buffer);
#ifdef XTRACE #ifdef XTRACE
{ char cmd [1024]; { char cmd [128];
sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size); sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size);
os_cli (cmd); os_cli (cmd);
} }
#endif #endif
if (wimpt_complain (xjpeginfo_dimensions jid.s.image.addr = ramfetch_buffer;
((jpeg_image *) &ramfetch_buffer [12], ram_size, NULL, &width, jid.s.image.size = ram_size;
&height, NULL, NULL)) != NULL) jid.tag = jpeg_id_addr;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)) != NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer); { flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
sprite_size = psprite_size (width, height, wimpt_mode (), /*mask?*/ FALSE, sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
2 /*full palette*/); FALSE /*mask?*/, 2 /*full palette*/);
if ((area = m_ALLOC (sprite_size + sizeof (sprite_area))) == NULL) if ((area = m_ALLOC (sprite_size + sizeof (sprite_area))) == NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer); { flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
/*... redirect output into 'area + sizeof (sprite_area)' ...*/ /*Create an empty sprite called '!newjpeg' in area*/
area->size = sprite_size + sizeof (sprite_area); header = main_make_newjpeg(area, sprite_size, &jinfo);
area->number = 1;
area->sproff = 16;
area->freeoff = sprite_size + sizeof (sprite_area);
header = (sprite_header *) ((char *) area + sizeof (sprite_area));
header->next = sprite_size;
strcpy (header->name, "!newjpeg");
header->width = ((width << log2_bpp) - 1)/32;
header->height = height - 1;
header->lbit = 0;
header->rbit = (width << log2_bpp) - 32*header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2_bpp <= 3? 8 << (1 << log2_bpp): 0);
header->mode = log2_bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
/*Set the name with a sprite op to get the case right.*/ /*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512, if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
area, header, ms->leaf)) != NULL) area, header, ms->leaf)) != NULL)
...@@ -952,43 +984,29 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms) ...@@ -952,43 +984,29 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
return FALSE; return FALSE;
} }
if (wimpt_complain (_swix (OS_SpriteOp, jid.s.image.addr = ramfetch_buffer; /*Might have shifted*/
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3), if (wimpt_complain (main_plot_fromjpeg (area, header, &jid)) != NULL)
0x23C, area, header, 0, &s1, &s2, &s3)) != NULL)
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
if (wimpt_complain (xjpeg_plot_scaled ((jpeg_image *) &ramfetch_buffer [12],
0, 0, NULL, ram_size, jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL)
{ m_FREE (area, sprite_size + sizeof (sprite_area)); { m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer); flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
/*... direct output back ...*/ if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + sizeof (sprite_area)))
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
{ m_FREE (area, sprite_size + sizeof (sprite_area)); { m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer); flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE; return FALSE;
} }
if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + 12)) /*Make it look like a sprite file by trimming off 4 bytes*/
{ m_FREE (area, sprite_size + sizeof (sprite_area)); memcpy (ramfetch_buffer, &area->number,
flex_free ((flex_ptr) &ramfetch_buffer); sprite_size + sizeof (sprite_area) - sizeof (area->size));
return FALSE; #ifdef XTRACE
} { char cmd [128];
sprintf (cmd, "%%Save $.Sprite %X +%X", &area->size,
memcpy (ramfetch_buffer, (char *) area + 4, sprite_size + 12); sprite_size + sizeof (sprite_area) - sizeof (area->size));
#ifdef XTRACE
{ char cmd [1024];
sprintf (cmd, "%%Save $.Sprite %X +%X", ramfetch_buffer,
sprite_size + 12);
os_cli (cmd); os_cli (cmd);
} }
#endif #endif
m_FREE (area, sprite_size + sizeof (sprite_area)); m_FREE (area, sprite_size + sizeof (sprite_area));
} }
...@@ -1282,17 +1300,17 @@ void main_check_position (main_window *w) ...@@ -1282,17 +1300,17 @@ void main_check_position (main_window *w)
static int Load_File (main_window *window, char *filename, int merge, static int Load_File (main_window *window, char *filename, int merge,
int safe) int safe)
/*Copes with JPEGs now. J R C 24th Jun 1994*/
{ int rc = 1, i = 0, offset, ramcopy = filename == (char *) -1, { int rc = 1, i = 0, offset, ramcopy = filename == (char *) -1,
temp_file = !(safe || xferrecv_file_is_safe ()), file_type = FileType_Sprite, temp_file = !(safe || xferrecv_file_is_safe ()), file_type = FileType_Sprite,
sprite_size, width, height, s1, s2, s3, sprite_size,
log2_bpp = bbc_modevar (-1, bbc_Log2BPP); log2_bpp = bbc_modevar (-1, bbc_Log2BPP);
os_filestr filestr; os_filestr filestr;
main_sprite *sprite, **sprptr; main_sprite *sprite, **sprptr;
sprite_header *header; sprite_header *header;
main_file *file = &window->data->file; main_file *file = &window->data->file;
wimp_winfo curr; wimp_winfo curr;
jpeg_id jid;
jpeg_info jinfo;
if (window->selection.flags & MW_SELSAVING) return 0; if (window->selection.flags & MW_SELSAVING) return 0;
...@@ -1321,7 +1339,7 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1321,7 +1339,7 @@ static int Load_File (main_window *window, char *filename, int merge,
} }
file_type = (filestr.loadaddr & 0xFFF00) >> 8; file_type = (filestr.loadaddr & 0xFFF00) >> 8;
if (!(file_type == FileType_Sprite || file_type == jpeg_FILE_TYPE)) if (!(file_type == FileType_Sprite || file_type == FileType_JPEG))
{ werr (FALSE, msgs_lookup ("PntEB"), filename); { werr (FALSE, msgs_lookup ("PntEB"), filename);
return 0; /* failed */ return 0; /* failed */
} }
...@@ -1353,13 +1371,14 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1353,13 +1371,14 @@ static int Load_File (main_window *window, char *filename, int merge,
if (file_type == FileType_Sprite) if (file_type == FileType_Sprite)
sprite_size = filestr.start - 12; sprite_size = filestr.start - 12;
else else
{ if (wimpt_complain (xjpegfileinfo_dimensions (filename, NULL, &width, { jid.s.name = filename;
&height, NULL, NULL))) jid.tag = jpeg_id_name;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)))
return 0; return 0;
ftracef2 ("JPEG info: %d x %d\n", width, height); ftracef2 ("JPEG info: %d x %d\n", jinfo.width, jinfo.height);
sprite_size = psprite_size (width, height, wimpt_mode (), /*mask?*/ FALSE, sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
2 /*full palette*/); FALSE /*mask?*/, 2 /*full palette*/);
} }
if (merge) if (merge)
...@@ -1385,23 +1404,8 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1385,23 +1404,8 @@ static int Load_File (main_window *window, char *filename, int merge,
else else
{ char *cc; { char *cc;
/*... redirect output into 'file->spritearea + sizeof (sprite_area)' ...*/ /*Create an empty sprite called '!newjpeg' in ramfetch_buffer*/
((int *) ramfetch_buffer) [0] = sprite_size + sizeof (sprite_area); header = main_make_newjpeg((sprite_area *)ramfetch_buffer, sprite_size, &jinfo);
((int *) ramfetch_buffer) [1] = 1;
((int *) ramfetch_buffer) [2] = 16;
((int *) ramfetch_buffer) [3] = sprite_size + sizeof (sprite_area);
header = (sprite_header *) ((char *) ramfetch_buffer + sizeof (sprite_area));
header->next = sprite_size;
strcpy (header->name, "!newjpeg");
header->width = ((width << log2_bpp) - 1)/32;
header->height = height - 1;
header->lbit = 0;
header->rbit = (width << log2_bpp) - 32*header->width - 1;
header->image =
header->mask = sizeof (sprite_header) +
(log2_bpp <= 3? 8 << (1 << log2_bpp): 0);
header->mode = log2_bpp + 1 << 27 | 180/wimpt_dy () << 14 |
180/wimpt_dx () << 1 | 1;
/*Set the name with a sprite op to get the case right.*/ /*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512, if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
...@@ -1420,19 +1424,8 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1420,19 +1424,8 @@ static int Load_File (main_window *window, char *filename, int merge,
header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL) header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
return -1; return -1;
if (wimpt_complain (_swix (OS_SpriteOp, if (wimpt_complain (main_plot_fromjpeg ((sprite_area *)ramfetch_buffer, header, &jid)) != NULL)
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3), return -1;
0x23C, ramfetch_buffer, header, 0, &s1, &s2, &s3)) != NULL)
return -1;
if (wimpt_complain (xjpeg_plot_file_scaled (filename, 0, 0, NULL,
jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL)
return -1;
/*... direct output back ...*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
return -1;
rc = 1; rc = 1;
} }
...@@ -1499,23 +1492,8 @@ static int Load_File (main_window *window, char *filename, int merge, ...@@ -1499,23 +1492,8 @@ static int Load_File (main_window *window, char *filename, int merge,
else else
{ char *cc; { char *cc;
/*... redirect output into 'file->spritearea + sizeof (sprite_area)' ...*/ /*Create an empty sprite called '!newjpeg' in file->spritearea*/
file->spritearea->number = 1; header = main_make_newjpeg(file->spritearea, sprite_size, &jinfo);
file->spritearea->sproff = 16;
file->spritearea->freeoff = sprite_size + sizeof (sprite_area);