/// <summary>
        /// Convert encoded band layer structure into byte stream.
        /// </summary>
        /// <param name = "bandData">The structure data to be converted into byte stream.</param>
        public byte[] ToBytes(CLEARCODEC_BAND bandData)
        {
            List <byte> bufList = new List <byte>();

            bufList.AddRange(TypeMarshal.ToBytes <ushort>(bandData.xStart));
            bufList.AddRange(TypeMarshal.ToBytes <ushort>(bandData.xEnd));
            bufList.AddRange(TypeMarshal.ToBytes <ushort>(bandData.yStart));
            bufList.AddRange(TypeMarshal.ToBytes <ushort>(bandData.yEnd));

            bufList.AddRange(TypeMarshal.ToBytes <byte>(bandData.blueBkg));
            bufList.AddRange(TypeMarshal.ToBytes <byte>(bandData.greenBkg));
            bufList.AddRange(TypeMarshal.ToBytes <byte>(bandData.redBkg));

            for (int i = 0; i < bandData.vBars.Count(); i++)
            {
                if (bandData.vBars[i].type == VBAR_TYPE.VBAR_CACHE_HIT)  // 1 bit check.
                {
                    VBAR_CACHE_HIT vbarCacheHit = bandData.vBars[i].vbarCacheHit;
                    bufList.AddRange(ToBytes(vbarCacheHit));

                    if (ccTestType == RdpegfxNegativeTypes.ClearCodec_Band_VBarCacheHit_ShortVBarPixelsExist)
                    {
                        // Add an additional pixel into encoded data.
                        Color_RGB pixel = new Color_RGB();
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.B));
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.G));
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.R));
                    }
                }
                else if (bandData.vBars[i].type == VBAR_TYPE.SHORT_VBAR_CACHE_HIT)  // 2 bits check.
                {
                    SHORT_VBAR_CACHE_HIT svbarCacheHit = bandData.vBars[i].shortVbarCacheHit;
                    bufList.AddRange(ToBytes(svbarCacheHit));

                    if (ccTestType == RdpegfxNegativeTypes.ClearCodec_Band_ShortVBarCacheHit_ShortVBarPixelsExist)
                    {
                        // add an additional pixel into encoded data
                        Color_RGB pixel = new Color_RGB();
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.B));
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.G));
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.R));
                    }
                }
                else if (bandData.vBars[i].type == VBAR_TYPE.SHORT_VBAR_CACHE_MISS)  // 2 bits check.
                {
                    SHORT_VBAR_CACHE_MISS svbarCacheMiss = bandData.vBars[i].shortVbarCacheMiss;
                    bufList.AddRange(ToBytes(svbarCacheMiss));
                }
            }
            return(bufList.ToArray());
        }
        /// <summary>
        /// Convert SHORT_VBAR_CACHE_MISS structure into byte stream.
        /// </summary>
        /// <param name = "cacheMiss"> the structure data to be converted into byte stream </param>
        public byte[] ToBytes(SHORT_VBAR_CACHE_MISS cacheMiss)
        {
            List <byte> bufList = new List <byte>();

            bufList.AddRange(TypeMarshal.ToBytes <ushort>(cacheMiss.shortVBarYOnOff_x));

            if (ccTestType != RdpegfxNegativeTypes.ClearCodec_Band_ShortVBarCacheMiss_IncorrectPixelNumber)
            {
                if (cacheMiss.shortVBarPixels != null)
                {
                    for (int i = 0; i < cacheMiss.shortVBarPixels.Count(); i++)
                    {
                        Color_RGB pixel = cacheMiss.shortVBarPixels[i];
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.B));
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.G));
                        bufList.AddRange(TypeMarshal.ToBytes <byte>(pixel.R));
                    }
                }
            }

            return(bufList.ToArray());
        }
        /// <summary>
        /// Convert SHORT_VBAR_CACHE_MISS structure into byte stream.
        /// </summary>
        /// <param name = "cacheMiss"> the structure data to be converted into byte stream </param>
        public byte[] ToBytes(SHORT_VBAR_CACHE_MISS cacheMiss)
        {
            List<byte> bufList = new List<byte>();

            bufList.AddRange(TypeMarshal.ToBytes<ushort>(cacheMiss.shortVBarYOnOff_x));

            if (ccTestType != RdpegfxNegativeTypes.ClearCodec_Band_ShortVBarCacheMiss_IncorrectPixelNumber)
            {
                if (cacheMiss.shortVBarPixels != null)
                {
                    for (int i = 0; i < cacheMiss.shortVBarPixels.Count(); i++)
                    {
                        Color_RGB pixel = cacheMiss.shortVBarPixels[i];
                        bufList.AddRange(TypeMarshal.ToBytes<byte>(pixel.B));
                        bufList.AddRange(TypeMarshal.ToBytes<byte>(pixel.G));
                        bufList.AddRange(TypeMarshal.ToBytes<byte>(pixel.R));
                    }
                }
            }

            return bufList.ToArray();
        }