Skip to content

Commit

Permalink
remove appending functionality that never realized to anything useful
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Oct 31, 2023
1 parent 574dce7 commit bcad183
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 41 deletions.
24 changes: 1 addition & 23 deletions img/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,25 +912,14 @@ apc_img_save( Handle self, char * fileName, Bool is_utf8, PImgIORequest ioreq, H
CHK;
memset( &fi, 0, sizeof( fi));

if ( pexist( append) && pget_B( append))
fi. append = true;

if ( pexist( autoConvert))
autoConvert = pget_B( autoConvert);

/* open file */
if ( fi. append && ioreq == NULL) {
FILE * f = ( FILE *) prima_open_file( fileName, is_utf8, "rb");
if ( !f)
fi. append = false;
else
fclose( f);
}

fi. errbuf = error ? error : dummy_error_buf;
if ( ioreq == NULL) {
memcpy( &sioreq, &std_ioreq, sizeof( sioreq));
if (( sioreq. handle = prima_open_file( fileName, is_utf8, fi. append ? "rb+" : "wb+" )) == NULL)
if (( sioreq. handle = prima_open_file( fileName, is_utf8, "wb+" )) == NULL)
out( strerror( errno));
fi. req = &sioreq;
fi. req_is_stdio = true;
Expand Down Expand Up @@ -1044,9 +1033,6 @@ apc_img_save( Handle self, char * fileName, Bool is_utf8, PImgIORequest ioreq, H
if ( fi. frameMapSize > 1 &&
!( c-> info-> IOFlags & IMG_SAVE_MULTIFRAME))
out("Codec cannot save mutiframe images");
if ( fi. append &&
!( c-> info-> IOFlags & IMG_SAVE_APPEND))
out("Codec cannot append frames");

if (( fi. instance = c-> vmt-> open_save( c, &fi)) == NULL)
out("Codec cannot handle this file");
Expand Down Expand Up @@ -1097,11 +1083,6 @@ apc_img_save( Handle self, char * fileName, Bool is_utf8, PImgIORequest ioreq, H
c = NULL;
continue;
}
if ( fi. append
&& !( c-> info-> IOFlags & IMG_SAVE_APPEND)) {
c = NULL;
continue;
}

if ( !autoConvert) {
int j, *k = c-> info-> saveTypes, ok = 0;
Expand Down Expand Up @@ -1354,7 +1335,6 @@ apc_img_info2hash( PImgCodec codec)
pset_i( canSave , c-> IOFlags & IMG_SAVE_TO_FILE);
pset_i( canSaveStream , c-> IOFlags & IMG_SAVE_TO_STREAM);
pset_i( canSaveMultiple, c-> IOFlags & IMG_SAVE_MULTIFRAME);
pset_i( canAppend, c-> IOFlags & IMG_SAVE_APPEND);

fill_ilist( "types", c-> saveTypes, profile);

Expand Down Expand Up @@ -1388,8 +1368,6 @@ apc_img_info2hash( PImgCodec codec)

if ( c-> IOFlags & ( IMG_SAVE_TO_FILE|IMG_SAVE_TO_STREAM)) {
hv = codec-> vmt-> save_defaults( codec);
if ( c-> IOFlags & IMG_SAVE_MULTIFRAME)
(void) hv_store( hv, "append", 6, newSViv(0), 0);
(void) hv_store( hv, "autoConvert", 11, newSViv(1), 0);
(void) hv_store( hv, "codecID", 7, newSVsv( NULL_SV), 0);
} else
Expand Down
2 changes: 0 additions & 2 deletions include/img.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ typedef struct _ImgSaveFileInstance {
Bool is_utf8;
PImgIORequest req;
Bool req_is_stdio;
Bool append; /* true if append, false if rewrite */

/* instance data, filled by open_save */
void * instance; /* result of open, user data for save session */
Expand All @@ -122,7 +121,6 @@ typedef struct _ImgSaveFileInstance {
#define IMG_SAVE_TO_FILE 0x0000010
#define IMG_SAVE_TO_STREAM 0x0000020
#define IMG_SAVE_MULTIFRAME 0x0000040
#define IMG_SAVE_APPEND 0x0000080

/* codec info */
typedef struct _ImgCodecInfo {
Expand Down
8 changes: 2 additions & 6 deletions pod/Prima/codecs.pod
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,11 @@ F<img/codec_X11.c>, which defines extra hotspot coordinates, X and Y.
A saving request takes into account the image types that the codec previously
declared to support, and that are defined in the C<< PImgCodecInfo-> saveTypes >> array.
Prima converts an image to be saved into one of these formats,
before the actual C<save()> call takes place. Another boolean flag,
C<< PImgSaveFileInstance-> append >> is used to decide whether it is appending
(true) to rewriting a file (false) is expected to happen, however this
functionality is under design. Due to the increased complexity of the code, that
should respond to the C<append> flag, this behavior is not required.
before the actual C<save()> call takes place.

A codec may also set two of C<PImgCodecInfo> flags, C<canSave> and
C<canSaveMultiple>. Save requests will never be called if C<canSave> is false,
and correspondingly, the append requests along with multiframe save requests
and correspondingly, the multiframe save requests
would be never invoked for a codec with C<canSaveMultiple> set to false. The
scenario for a multiframe save request is the same as for a multiframe loading
request. All the issues concerning palette, data converting, and saving extra
Expand Down
10 changes: 0 additions & 10 deletions pod/Prima/image-load.pod
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,6 @@ When the conversion takes place, the Image property C<conversion> is used
for the selection of the error distribution algorithm if down-sampling
is required.

=head2 Appending frames to an existing file

This functionality is under design, but the common outlines are already set.
The parameter C<append> ( 0 by default ) triggers this behavior - if it is set,
then an append attempt is made.

=head1 Managing the codecs

Prima provides the C<< Prima::Image-> codecs >> function that returns an
Expand Down Expand Up @@ -461,10 +455,6 @@ an index more than zero, 0 otherwise

Is set if the codec can save more than one frame

=item canAppend

Is set if the codec can append frames to an existing file

=item types

An array of integers - each is a combination of the C<im::XXX> flags, the image
Expand Down

0 comments on commit bcad183

Please sign in to comment.