mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-30 11:10:52 +01:00
add compression to png encoder
This commit is contained in:
parent
eb7d98d6ba
commit
4a3150bf89
@ -1,4 +1,5 @@
|
|||||||
import { RenderTexture } from '@pixi/core';
|
import { RenderTexture } from '@pixi/core';
|
||||||
|
import { deflate, DeflateFunctionOptions } from 'pako';
|
||||||
import { BinaryWriter } from '../../core/communication/codec/BinaryWriter';
|
import { BinaryWriter } from '../../core/communication/codec/BinaryWriter';
|
||||||
import { TextureUtils } from '../../room';
|
import { TextureUtils } from '../../room';
|
||||||
|
|
||||||
@ -59,7 +60,12 @@ export class PNGEncoder
|
|||||||
|
|
||||||
writer3.writeBytes(imagePixelData);
|
writer3.writeBytes(imagePixelData);
|
||||||
|
|
||||||
PNGEncoder.writeChunk(writer1, 1229209940, writer3);
|
const writer4 = new BinaryWriter();
|
||||||
|
const defaultZlibOptions: DeflateFunctionOptions = {
|
||||||
|
level: 3,
|
||||||
|
};
|
||||||
|
writer4.writeBytes(deflate(new Uint8Array(writer3.getBuffer()), defaultZlibOptions));
|
||||||
|
PNGEncoder.writeChunk(writer1, 1229209940, writer4);
|
||||||
PNGEncoder.writeChunk(writer1, 1229278788, null);
|
PNGEncoder.writeChunk(writer1, 1229278788, null);
|
||||||
|
|
||||||
return writer1.getBuffer();
|
return writer1.getBuffer();
|
||||||
|
Loading…
Reference in New Issue
Block a user