Ignore:
Timestamp:
2021-11-24T15:13:46+13:00 (2 years ago)
Author:
cstephen
Message:

Implement edit saving

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/EditPage.vue

    r35743 r35746  
    2323            </table>
    2424
    25             <img ref="image" :src="imageUrl" class="image" :style="{ filter: filterString }" />
     25            <img ref="image" :src="src" class="image" :style="{ filter: filterString }" />
    2626        </div>
    2727    </div>
    2828
    2929    <div class="control-panel">
    30         <button class="btn-fab" @click="$emit('closeRequested')">
     30        <button class="btn-fab" @click="$emit('closeAndDiscard')">
     31            <span class="material-icons mdi-l">cancel</span>
     32        </button>
     33
     34        <button class="btn-fab" @click="closeAndSave">
    3135            <span class="material-icons mdi-l">save</span>
    3236        </button>
     
    151155    },
    152156    props: {
    153         image: File
    154     },
     157        imageBuffer: ArrayBuffer,
     158        src: String
     159    },
     160    emits: [ "closeAndDiscard", "closeAndSave" ],
    155161    data() {
    156162        return {
    157             imageUrl: URL.createObjectURL(this.image),
    158163            invert: false,
    159164            rotation: 0,
     
    183188    },
    184189    methods: {
    185         async getImageBlobAsync() {
    186             const buffer = Buffer.from(this.image.arrayBuffer());
     190        async closeAndSave() {
     191            const buffer = Buffer.from(this.imageBuffer);
    187192            const that = this;
    188193
     
    193198                    }
    194199
    195                     // if (that.rotation !== 0) {
    196                     //     image.rotate(that.rotation);
    197                     // }
     200                    if (that.rotation !== 0) {
     201                        image.rotate(-that.rotation);
     202                    }
    198203
    199204                    return await image.getBufferAsync(Jimp.MIME_PNG);
    200205                });
    201206
    202             return new Blob([ modifiedBuffer ], { type: Jimp.MIME_PNG });
     207            this.$emit("closeAndSave", modifiedBuffer, Jimp.MIME_PNG);
    203208        },
    204209
Note: See TracChangeset for help on using the changeset viewer.