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 = \
debug.${APP}.Templates
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\
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\
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
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
......
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.04"
Module_Version SETA 204
Module_MajorVersion SETS "2.05"
Module_Version SETA 205
Module_MinorVersion SETS ""
Module_Date SETS "07 Dec 2010"
Module_ApplicationDate SETS "07-Dec-10"
Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.04"
Module_HelpVersion SETS "2.04 (07 Dec 2010)"
Module_FullVersion SETS "2.05"
Module_HelpVersion SETS "2.05 (07 Dec 2010)"
END
/* (2.04)
/* (2.05)
*
* This file is automatically maintained by srccommit, do not edit manually.
* 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_Date_CMHG 07 Dec 2010
#define Module_MajorVersion "2.04"
#define Module_Version 204
#define Module_MajorVersion "2.05"
#define Module_Version 205
#define Module_MinorVersion ""
#define Module_Date "07 Dec 2010"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.04"
#define Module_HelpVersion "2.04 (07 Dec 2010)"
#define Module_LibraryVersionInfo "2:4"
#define Module_FullVersion "2.05"
#define Module_HelpVersion "2.05 (07 Dec 2010)"
#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)
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,
wimp_box *spritebbox, wimp_box *namebbox)
......@@ -849,7 +892,7 @@ static int ramfetch_buffer_extender (char **buffer, int *size)
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);
sprite_area *area;
sprite_header *header;
......@@ -858,7 +901,7 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
/*only interested in sprites*/
/*and jpeg's. J R C 27th Jun 1994*/
if (!((file_type = xferrecv_checkimport (&size)) == FileType_Sprite ||
file_type == jpeg_FILE_TYPE))
file_type == FileType_JPEG))
{ werr (FALSE, msgs_lookup ("PntEB"), ms->leaf);
return FALSE;
}
......@@ -887,53 +930,42 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
return FALSE;
}
if (file_type == jpeg_FILE_TYPE)
{ /*For JPEG's, we find it convenient to read the file data into
|ramfetch_buffer| (since that is how ramfetch_buffer_extender () is set
if (file_type == FileType_JPEG)
{ jpeg_id jid;
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,
paint the sprite and copy it back into |ramfetch_buffer|.*/
ram_size = flex_size ((flex_ptr) &ramfetch_buffer);
#ifdef XTRACE
{ char cmd [1024];
sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size);
os_cli (cmd);
}
#endif
#ifdef XTRACE
{ char cmd [128];
sprintf (cmd, "%%Save $.JPEG %X +%X", ramfetch_buffer, ram_size);
os_cli (cmd);
}
#endif
if (wimpt_complain (xjpeginfo_dimensions
((jpeg_image *) &ramfetch_buffer [12], ram_size, NULL, &width,
&height, NULL, NULL)) != NULL)
jid.s.image.addr = ramfetch_buffer;
jid.s.image.size = ram_size;
jid.tag = jpeg_id_addr;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)) != NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
sprite_size = psprite_size (width, height, wimpt_mode (), /*mask?*/ FALSE,
2 /*full palette*/);
sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
FALSE /*mask?*/, 2 /*full palette*/);
if ((area = m_ALLOC (sprite_size + sizeof (sprite_area))) == NULL)
{ flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
/*... redirect output into 'area + sizeof (sprite_area)' ...*/
area->size = sprite_size + sizeof (sprite_area);
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;
/*Create an empty sprite called '!newjpeg' in area*/
header = main_make_newjpeg(area, sprite_size, &jinfo);
/*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
area, header, ms->leaf)) != NULL)
......@@ -952,43 +984,29 @@ static BOOL ramtransfer_file (wimp_msgdatasave *ms)
return FALSE;
}
if (wimpt_complain (_swix (OS_SpriteOp,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3),
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)
jid.s.image.addr = ramfetch_buffer; /*Might have shifted*/
if (wimpt_complain (main_plot_fromjpeg (area, header, &jid)) != NULL)
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
/*... direct output back ...*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + sizeof (sprite_area)))
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
if (!flex_extend ((flex_ptr) &ramfetch_buffer, sprite_size + 12))
{ m_FREE (area, sprite_size + sizeof (sprite_area));
flex_free ((flex_ptr) &ramfetch_buffer);
return FALSE;
}
memcpy (ramfetch_buffer, (char *) area + 4, sprite_size + 12);
#ifdef XTRACE
{ char cmd [1024];
sprintf (cmd, "%%Save $.Sprite %X +%X", ramfetch_buffer,
sprite_size + 12);
/*Make it look like a sprite file by trimming off 4 bytes*/
memcpy (ramfetch_buffer, &area->number,
sprite_size + sizeof (sprite_area) - sizeof (area->size));
#ifdef XTRACE
{ char cmd [128];
sprintf (cmd, "%%Save $.Sprite %X +%X", &area->size,
sprite_size + sizeof (sprite_area) - sizeof (area->size));
os_cli (cmd);
}
#endif
#endif
m_FREE (area, sprite_size + sizeof (sprite_area));
}
......@@ -1282,17 +1300,17 @@ void main_check_position (main_window *w)
static int Load_File (main_window *window, char *filename, int merge,
int safe)
/*Copes with JPEGs now. J R C 24th Jun 1994*/
{ int rc = 1, i = 0, offset, ramcopy = filename == (char *) -1,
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);
os_filestr filestr;
main_sprite *sprite, **sprptr;
sprite_header *header;
main_file *file = &window->data->file;
wimp_winfo curr;
jpeg_id jid;
jpeg_info jinfo;
if (window->selection.flags & MW_SELSAVING) return 0;
......@@ -1321,7 +1339,7 @@ static int Load_File (main_window *window, char *filename, int merge,
}
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);
return 0; /* failed */
}
......@@ -1353,13 +1371,14 @@ static int Load_File (main_window *window, char *filename, int merge,
if (file_type == FileType_Sprite)
sprite_size = filestr.start - 12;
else
{ if (wimpt_complain (xjpegfileinfo_dimensions (filename, NULL, &width,
&height, NULL, NULL)))
{ jid.s.name = filename;
jid.tag = jpeg_id_name;
if (wimpt_complain (jpeg_readinfo (&jid, &jinfo)))
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,
2 /*full palette*/);
sprite_size = psprite_size (jinfo.width, jinfo.height, wimpt_mode (),
FALSE /*mask?*/, 2 /*full palette*/);
}
if (merge)
......@@ -1385,23 +1404,8 @@ static int Load_File (main_window *window, char *filename, int merge,
else
{ char *cc;
/*... redirect output into 'file->spritearea + sizeof (sprite_area)' ...*/
((int *) ramfetch_buffer) [0] = sprite_size + sizeof (sprite_area);
((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;
/*Create an empty sprite called '!newjpeg' in ramfetch_buffer*/
header = main_make_newjpeg((sprite_area *)ramfetch_buffer, sprite_size, &jinfo);
/*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
......@@ -1420,19 +1424,8 @@ static int Load_File (main_window *window, char *filename, int merge,
header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
return -1;
if (wimpt_complain (_swix (OS_SpriteOp,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3),
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;
if (wimpt_complain (main_plot_fromjpeg ((sprite_area *)ramfetch_buffer, header, &jid)) != NULL)
return -1;
rc = 1;
}
......@@ -1499,23 +1492,8 @@ static int Load_File (main_window *window, char *filename, int merge,
else
{ char *cc;
/*... redirect output into 'file->spritearea + sizeof (sprite_area)' ...*/
file->spritearea->number = 1;
file->spritearea->sproff = 16;
file->spritearea->freeoff = sprite_size + sizeof (sprite_area);
header = (sprite_header *) ((int) file->spritearea + 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;
/*Create an empty sprite called '!newjpeg' in file->spritearea*/
header = main_make_newjpeg(file->spritearea, sprite_size, &jinfo);
/*Set the name with a sprite op to get the case right.*/
if (wimpt_complain (os_swix4 (OS_SpriteOp, 0x1A | 512,
......@@ -1534,18 +1512,7 @@ static int Load_File (main_window *window, char *filename, int merge,
header + 1, 8 << (1 << log2_bpp), 1 << 1)) != NULL)
rc = -1;
if (wimpt_complain (_swix (OS_SpriteOp,
_IN(0)|_IN(1)|_IN(2)|_IN(3)|_OUT(1)|_OUT(2)|_OUT(3),
0x23C, file->spritearea, header, 0, &s1, &s2, &s3)) != NULL)
rc = -1;
if (wimpt_complain (xjpeg_plot_file_scaled (filename, 0, 0, NULL,
jpeg_SCALE_DITHERED | jpeg_SCALE_ERROR_DIFFUSED)) != NULL)
rc = -1;
/*... direct output back ...*/
if (wimpt_complain (_swix (OS_SpriteOp, _IN(0)|_IN(1)|_IN(2)|_IN(3),
0x23C, s1, s2, s3)) != NULL)
if (wimpt_complain (main_plot_fromjpeg (file->spritearea, header, &jid)) != NULL)
rc = -1;
}
......@@ -1853,24 +1820,24 @@ static BOOL main_select_area (wimp_eventstr *event, void *handle)
{ wimp_wstate ws;
wimp_box clip;
main_window *window = (main_window *)handle;
if (event->e != wimp_EUSERDRAG) return 0;
if (event->e != wimp_EUSERDRAG) return FALSE;
win_remove_unknown_event_processor (main_select_area, handle);
os_swix1 (Wimp_AutoScroll, 0);
wimp_get_wind_state (window->handle,&ws);
wimp_get_wind_state (window->handle, &ws);
clip.x0=SCREEN_TO_WORKAREA_X(&ws, MIN(event->data.dragbox.x0, event->data.dragbox.x1));
clip.x1=SCREEN_TO_WORKAREA_X(&ws, MAX(event->data.dragbox.x0, event->data.dragbox.x1));
clip.y0=SCREEN_TO_WORKAREA_Y(&ws, MIN(event->data.dragbox.y0, event->data.dragbox.y1));
clip.y1=SCREEN_TO_WORKAREA_Y(&ws, MAX(event->data.dragbox.y0, event->data.dragbox.y1));
clip.x0 = SCREEN_TO_WORKAREA_X(&ws, MIN(event->data.dragbox.x0, event->data.dragbox.x1));
clip.x1 = SCREEN_TO_WORKAREA_X(&ws, MAX(event->data.dragbox.x0, event->data.dragbox.x1));
clip.y0 = SCREEN_TO_WORKAREA_Y(&ws, MIN(event->data.dragbox.y0, event->data.dragbox.y1));
clip.y1 = SCREEN_TO_WORKAREA_Y(&ws, MAX(event->data.dragbox.y0, event->data.dragbox.y1));
main_clear_selection (window,&clip,(window->selection.flags & MW_SELDRAGRIGHT )?SI_TOGGLE:SI_SELECT);
return 1;
return TRUE;
}
int main_selection_file_size (main_window *window)
{ main_sprite *sprite;
int size=0;
int size = 0;
if (!window || window->selection.count==0) return 0;
for (sprite=window->data->file.sprites;sprite != NULL; sprite = sprite->link)
{
......@@ -2423,7 +2390,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
int type;
type = xferrecv_checkinsert (&name); /* sets up reply */
if (type == FileType_Sprite || type == jpeg_FILE_TYPE)
if (type == FileType_Sprite || type == FileType_JPEG)
{ int ok;
ftracef1 ("Loading file \"%s\"\n", name);
visdelay_begin ();
......
/* Copyright 1996 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef jpeg_H
#define jpeg_H
/* C header file for JPEG
* written by DefMod (Sep 7 1994) on Fri Sep 9 18:40:20 1994
* Copyright Acorn Computers Ltd, 1994
*/
/*************************************************************************
* This source file was written by Acorn Computers Limited. It is part *
* of the OSLib library for writing applications for RISC OS. It may be *
* used freely in the creation of programs for RISC OS. *
*************************************************************************/
#ifndef __drawmod_h
#include "drawmod.h"
#endif
/**********************************
* SWI names and SWI reason codes *
**********************************/
#undef JPEG_Info
#define JPEG_Info 0x49980
#undef XJPEG_Info
#define XJPEG_Info 0x69980
#undef JPEGInfo_Dimensions
#define JPEGInfo_Dimensions 0x1
#undef JPEG_FileInfo
#define JPEG_FileInfo 0x49981
#undef XJPEG_FileInfo
#define XJPEG_FileInfo 0x69981
#undef JPEGFileInfo_Dimensions
#define JPEGFileInfo_Dimensions 0x1
#undef JPEG_PlotScaled
#define JPEG_PlotScaled 0x49982
#undef XJPEG_PlotScaled
#define XJPEG_PlotScaled 0x69982
#undef JPEG_PlotFileScaled
#define JPEG_PlotFileScaled 0x49983
#undef XJPEG_PlotFileScaled
#define XJPEG_PlotFileScaled 0x69983
#undef JPEG_PlotTransformed
#define JPEG_PlotTransformed 0x49984
#undef XJPEG_PlotTransformed
#define XJPEG_PlotTransformed 0x69984
#undef JPEG_PlotFileTransformed
#define JPEG_PlotFileTransformed 0x49985
#undef XJPEG_PlotFileTransformed
#define XJPEG_PlotFileTransformed 0x69985
#undef JPEG_PDriverIntercept
#define JPEG_PDriverIntercept 0x49986
#undef XJPEG_PDriverIntercept
#define XJPEG_PDriverIntercept 0x69986
/************************************
* Structure and union declarations *
************************************/
typedef struct jpeg_image jpeg_image;
/********************
* Type definitions *
********************/
struct jpeg_image
{ int i [1];
};
#define jpeg_IMAGE(N) \
struct \
{ int i [N]; \
}
#define jpeg_SIZEOF_IMAGE(N) \
((N)*sizeof ((jpeg_image *) NULL)->i)
/************************
* Constant definitions *
************************/
#define jpeg_INFO_MONOCHROME 0x1u
#define jpeg_INFO_NO_TRFM 0x2u
#define jpeg_INFO_DPI_UNKNOWN 0x4u
#define jpeg_SCALE_DITHERED 0x1u
#define jpeg_SCALE_ERROR_DIFFUSED 0x2u
#define jpeg_GIVEN_RECTANGLE 0x1u
#define jpeg_TRANSFORM_DITHERED 0x2u
#define jpeg_TRANSFORM_ERROR_DIFFUSED 0x4u
#define jpeg_FILE_TYPE 3205
/*************************
* Function declarations *
*************************/
#ifdef __cplusplus