Ejemplo n.º 1
0
        /// <summary>
        /// Makes a new Anim object from any channel (or the value) of this one.
        /// </summary>
        /// <param name="iChannelOffset">Pick a channel to copy.  Set to -1 to take average of RGB.</param>
        /// <returns></returns>
        public Anim CopyAsGray(int iChannelOffset)
        {
            Anim animReturn = null;

            try {
                animReturn = new Anim();
                if (bmpLoaded != null)
                {
                    animReturn.bmpLoaded = (Bitmap)bmpLoaded.Clone();
                }
                animReturn.gunit             = gunit;
                animReturn.rectNowF          = new RectangleF(rectNowF.Left, rectNowF.Top, rectNowF.Width, rectNowF.Height);
                animReturn.rectNow           = new Rectangle(rectNow.Left, rectNow.Top, rectNow.Width, rectNow.Height);
                animReturn.lFramesCached     = lFramesCached;
                animReturn.sPathFileBaseName = sPathFileBaseName;
                animReturn.sFileExt          = sFileExt;
                //animReturn.sPathFile=sPathFile;
                animReturn.bFileSequence = bFileSequence;              //if use sPathFileBaseName+digits+"."+sExt, and sPathFile is first frame
                animReturn.iSeqDigitsMin = iSeqDigitsMin;              //, 0 if variable (i.exn. frame1.png...frame10.png)
                animReturn.lFrameNow     = lFrameNow;
                animReturn.lFrames       = lFrames;
                animReturn.iEffects      = iEffects;
                animReturn.imageOrig     = imageOrig;
                animReturn.iMaxEffects   = iMaxEffects;
                animReturn.lFramesCached = lFramesCached;
                if (lFramesCached == lFrames)
                {
                    animReturn.gbarrAnim = new GBuffer[lFramesCached];
                    if (iChannelOffset < 0)
                    {
                        for (long l = 0; l < lFrames; l++)
                        {
                            animReturn.gbarrAnim[l] = null;
                            GBuffer.MaskFromValue(ref animReturn.gbarrAnim[l], ref gbarrAnim[l]);
                        }
                    }
                    else
                    {
                        for (long l = 0; l < lFrames; l++)
                        {
                            animReturn.gbarrAnim[l] = null;
                            GBuffer.MaskFromChannel(ref animReturn.gbarrAnim[l], ref gbarrAnim[l], iChannelOffset);
                        }
                    }
                }
                else
                {
                    RReporting.ShowError("Uncached Anim not yet implemented", "anim CopyAsGray");
                }
                animReturn.gbFrame = animReturn.gbarrAnim[lFrameNow];
                if (iEffects > 0)
                {
                    animReturn.effectarr = new Effect[iEffects];
                    for (int i = 0; i < iEffects; i++)
                    {
                        animReturn.effectarr[i] = effectarr[i].Copy();
                    }
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "anim CopyAsGray");
            }
            return(animReturn);
        }        //end CopyAsGray