public ColorTransform ReadColorTransformWithAlpha() { this.Align8(); bool hasAdd = this.ReadBit(); bool hasMult = this.ReadBit(); HDRColor add = null; HDRColor mult = null; int numBits = (int)this.ReadUBits(4); if (hasMult) { int reds = this.ReadSBits(numBits); mult = new HDRColor(reds, this.ReadSBits(numBits), this.ReadSBits(numBits), this.ReadSBits(numBits)); } if (hasAdd) { add = new HDRColor(this.ReadSBits(numBits), this.ReadSBits(numBits), this.ReadSBits(numBits), this.ReadSBits(numBits)); } return(new ColorTransform(add, mult)); }
public void WriteColorTransform(ColorTransform cxform, bool withAlpha) { this.Align8(); this.WriteBit(cxform.HasAdd); this.WriteBit(cxform.HasMult); int numBits = 10; /* 10-bits for 9-bit 1.00 fixed 8.8 signed value */ this.WriteUBits(10, 4); if (cxform.HasMult) { HDRColor m = cxform.Mult; this.WriteColorComponent((int)m.Red, numBits); this.WriteColorComponent((int)m.Green, numBits); this.WriteColorComponent((int)m.Blue, numBits); if (withAlpha) { this.WriteColorComponent((int)m.Alpha, numBits); } } if (cxform.HasAdd) { HDRColor a = cxform.Add; this.WriteColorComponent((int)a.Red, numBits); this.WriteColorComponent((int)a.Green, numBits); this.WriteColorComponent((int)a.Blue, numBits); if (withAlpha) { this.WriteColorComponent((int)a.Alpha, numBits); } } }
/// <summary> /// Initializes a new instance of the ColorTransform class. /// </summary> /// <param name="add">A colour to be added. May be null</param> /// <param name="mult">A colour to be multiplied. May be null</param> public ColorTransform(HDRColor add, HDRColor mult) { this.Add = add; this.Mult = mult; }
/// <summary> /// Initializes a new instance of the ColorTransform class. /// </summary> /// <param name="add">A colour to be added. May be null</param> /// <param name="mult">A colour to be multiplied. May be null</param> public ColorTransform(HDRColor add, HDRColor mult) { this.Add = add; this.Mult = mult; }