Add base.PIXEL_FORMAT__ETC constants

This commit is contained in:
Nigel Tao committed 2020-06-09 12:34:34 +10:00
1 parent 983c5cd90e
commit 7e32336de0
10 files changed
+127 -46

No files matched your search

+3 -9
View File
@@ -137,15 +137,11 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
// The "((x + 3) >> 2) << 2" dance rounds x up.
this.bytes_per_row = ((((this.width as base.u64) * 3) + 3) >> 2) << 2
this.pad_per_row = this.width & 3
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__BGR magic pixfmt constant.
this.pixfmt = this.util.make_pixel_format(repr: 0x8000_0888)
this.pixfmt = this.util.make_pixel_format(repr: base.PIXEL_FORMAT__BGR)
} else if bits_per_pixel == 32 {
this.bytes_per_row = (this.width as base.u64) * 4
this.pad_per_row = 0
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL magic pixfmt constant.
this.pixfmt = this.util.make_pixel_format(repr: 0x8100_8888)
this.pixfmt = this.util.make_pixel_format(repr: base.PIXEL_FORMAT__BGRA_NONPREMUL)
} else {
// TODO: support other bits_per_pixel's.
return "#unsupported BMP file"
@@ -185,10 +181,8 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
this.frame_config_io_position = args.src.position()
if args.dst <> nullptr {
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL magic pixfmt constant.
args.dst.set!(
pixfmt: 0x8100_8888, // TODO: this.pixfmt instead?
pixfmt: base.PIXEL_FORMAT__BGRA_NONPREMUL, // TODO: this.pixfmt instead?
pixsub: 0,
width: this.width,
height: this.height,
+1 -3
View File
@@ -147,10 +147,8 @@ pub func config_decoder.decode_image_config?(dst: nptr base.image_config, src: b
}
if args.dst <> nullptr {
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
args.dst.set!(
pixfmt: 0x8304_0008,
pixfmt: base.PIXEL_FORMAT__INDEXED__BGRA_BINARY,
pixsub: 0,
width: this.width,
height: this.height,
+2 -6
View File
@@ -186,10 +186,8 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
}
if args.dst <> nullptr {
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
args.dst.set!(
pixfmt: 0x8304_0008,
pixfmt: base.PIXEL_FORMAT__INDEXED__BGRA_BINARY,
pixsub: 0,
width: this.width,
height: this.height,
@@ -878,12 +876,10 @@ pri func decoder.decode_id_part1?(dst: ptr base.pixel_buffer, src: base.io_reade
dst_palette = this.dst_palette[..]
}
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: dst_palette,
src_pixfmt: this.util.make_pixel_format(repr: 0x8304_0008),
src_pixfmt: this.util.make_pixel_format(repr: base.PIXEL_FORMAT__INDEXED__BGRA_BINARY),
src_palette: this.palettes[which_palette][..],
blend: args.blend)
if not status.is_ok() {
+2 -6
View File
@@ -82,10 +82,8 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
this.frame_config_io_position = args.src.position()
if args.dst <> nullptr {
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY magic pixfmt constant.
args.dst.set!(
pixfmt: 0x8304_0008,
pixfmt: base.PIXEL_FORMAT__INDEXED__BGRA_BINARY,
pixsub: 0,
width: this.width,
height: this.height,
@@ -149,12 +147,10 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
return base."@end of data"
}
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__Y magic pixfmt constant.
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: args.dst.palette(),
src_pixfmt: this.util.make_pixel_format(repr: 0x2000_0008),
src_pixfmt: this.util.make_pixel_format(repr: base.PIXEL_FORMAT__Y),
src_palette: this.util.empty_slice_u8(),
blend: args.blend)
if not status.is_ok() {