public RectMaterial(OptmizeClip baseClipP)
 {
  m_dX=0;
  m_dY=0;
  m_bUsed=false;
  SetBaseClip(baseClipP);
 }
Beispiel #2
0
 public RectMaterial(OptmizeClip baseClipP)
 {
     m_dX    = 0;
     m_dY    = 0;
     m_bUsed = false;
     SetBaseClip(baseClipP);
 }
Beispiel #3
0
 public bool Contains(OptmizeClip subClip)
 {
     if (subClip == null || subClip.clipElement == null)
     {
         return(false);
     }
     return(clipElement.clipRect.Contains(subClip.clipElement.clipRect));
 }
Beispiel #4
0
 private RectMaterial(RectMaterial pMaterial)
 {
     m_dX        = pMaterial.m_dX;
     m_dY        = pMaterial.m_dY;
     m_dHeight   = pMaterial.m_dHeight;
     m_dWidth    = pMaterial.m_dWidth;
     m_bUsed     = pMaterial.m_bUsed;
     optmizeClip = pMaterial.optmizeClip;
 }
 private RectMaterial(RectMaterial pMaterial)
 {
  m_dX=pMaterial.m_dX;
  m_dY=pMaterial.m_dY;
  m_dHeight=pMaterial.m_dHeight;
  m_dWidth=pMaterial.m_dWidth;
  m_bUsed=pMaterial.m_bUsed;
  optmizeClip = pMaterial.optmizeClip;
 }
Beispiel #6
0
 public void addSubClip(OptmizeClip subClipT)
 {
     subClips.Add(subClipT);
 }
Beispiel #7
0
 public void SetBaseClip(OptmizeClip baseClipP)
 {
     optmizeClip = baseClipP;
     m_dHeight   = optmizeClip.clipElement.clipRect.Height;
     m_dWidth    = optmizeClip.clipElement.clipRect.Width;
 }
Beispiel #8
0
        public void StartSort()
        {
            int keepWidth = 0;//保留宽度,所有切片中最大的宽度

            //计算保留尺寸
            for (int i = 0; i < m_MaterialList.Count; i++)
            {
                OptmizeClip baseClipElement = m_MaterialList[i].optmizeClip;
                if (keepWidth < baseClipElement.clipElement.clipRect.Width)
                {
                    keepWidth = baseClipElement.clipElement.clipRect.Width;
                }
            }
            keepWidth = MathUtil.getMultipleOfTwo(keepWidth);
            GenerateMaterial();
            Size minSize      = new Size(short.MaxValue, short.MaxValue);
            int  keepWidthBak = keepWidth;

            //int id = 0;
            while (true)
            {
                copyMaterial();
                //进行一次排样
                sort(0, m_MaterialList.Count, keepWidth, INFINITY, 0, 0);
                //获取本次排样结果
                Size newSize = getNeedSize();
                //比较两次结果
                bool replace = false;
                if (newSize.Width * newSize.Height < minSize.Width * minSize.Height)
                {
                    replace = true;
                }
                if (newSize.Width * newSize.Height == minSize.Width * minSize.Height)
                {
                    if (Math.Max(newSize.Width, newSize.Height) < Math.Max(minSize.Width, minSize.Height))
                    {
                        replace = true;
                    }
                }
                if (replace)
                {
                    minSize      = newSize;
                    keepWidthBak = keepWidth;
                }
                //测试生成的图片
                ////生成图片
                //Image imgExort = new Bitmap(newSize.Width, newSize.Height);
                //Graphics g = Graphics.FromImage(imgExort);
                //for (int j = 0; j < m_MaterialList.Count; j++)
                //{
                //    RectMaterial material = m_MaterialList[j];
                //    GraphicsUtil.drawClip(g, material.optmizeClip.clipElement.imageElement.image, (int)material.m_dX, (int)material.m_dY,
                //        material.optmizeClip.clipElement.clipRect.X, material.optmizeClip.clipElement.clipRect.Y, material.optmizeClip.clipElement.clipRect.Width,
                //        material.optmizeClip.clipElement.clipRect.Height, Consts.TRANS_NONE);
                //}
                //imgExort.Save(@"E:\project\EngineProject\CycloneEditor\test\test\testGen" + id + ".png");
                //id++;
                if (keepWidth >= 2048)
                {
                    break;
                }
                keepWidth *= 2;
            }
            //使用最后一次排序,再排一次
            if (keepWidthBak != keepWidth)
            {
                copyMaterial();
                //进行一次排样
                sort(0, m_MaterialList.Count, keepWidthBak, INFINITY, 0, 0);
            }
        }
 public bool Contains(OptmizeClip subClip)
 {
     if (subClip == null || subClip.clipElement == null)
     {
         return false;
     }
     return clipElement.clipRect.Contains(subClip.clipElement.clipRect);
 }
 public void addSubClip(OptmizeClip subClipT)
 {
     subClips.Add(subClipT);
 }
 public void SetBaseClip(OptmizeClip baseClipP)
 {
     optmizeClip = baseClipP;
     m_dHeight = optmizeClip.clipElement.clipRect.Height;
     m_dWidth = optmizeClip.clipElement.clipRect.Width;
 }