當前位置: 首頁>>代碼示例>>C#>>正文


C# PointF.Aspect方法代碼示例

本文整理匯總了C#中System.Drawing.PointF.Aspect方法的典型用法代碼示例。如果您正苦於以下問題:C# PointF.Aspect方法的具體用法?C# PointF.Aspect怎麽用?C# PointF.Aspect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.PointF的用法示例。


在下文中一共展示了PointF.Aspect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UI_OnTextureSelectionChanged

        private void UI_OnTextureSelectionChanged(bool newdraw)
        {
            FetchTexture tex = CurrentTexture;

            // reset high-water mark
            m_HighWaterStatusLength = 0;

            if (tex == null) return;

            bool newtex = (m_TexDisplay.texid != tex.ID);

            // save settings for this current texture
            if (m_Core.Config.TextureViewer_PerTexSettings)
            {
                if (!m_TextureSettings.ContainsKey(m_TexDisplay.texid))
                    m_TextureSettings.Add(m_TexDisplay.texid, new TexSettings());

                m_TextureSettings[m_TexDisplay.texid].r = customRed.Checked;
                m_TextureSettings[m_TexDisplay.texid].g = customGreen.Checked;
                m_TextureSettings[m_TexDisplay.texid].b = customBlue.Checked;
                m_TextureSettings[m_TexDisplay.texid].a = customAlpha.Checked;

                m_TextureSettings[m_TexDisplay.texid].displayType = channels.SelectedIndex;
                m_TextureSettings[m_TexDisplay.texid].customShader = customShader.Text;

                m_TextureSettings[m_TexDisplay.texid].depth = depthDisplay.Checked;
                m_TextureSettings[m_TexDisplay.texid].stencil = stencilDisplay.Checked;

                m_TextureSettings[m_TexDisplay.texid].mip = mipLevel.SelectedIndex;
                m_TextureSettings[m_TexDisplay.texid].slice = sliceFace.SelectedIndex;

                m_TextureSettings[m_TexDisplay.texid].minrange = rangeHistogram.BlackPoint;
                m_TextureSettings[m_TexDisplay.texid].maxrange = rangeHistogram.WhitePoint;

                m_TextureSettings[m_TexDisplay.texid].typeHint = m_Following.GetTypeHint(m_Core);
            }

            m_TexDisplay.texid = tex.ID;

            // interpret the texture according to the currently following type.
            if(!CurrentTextureIsLocked)
                m_TexDisplay.typeHint = m_Following.GetTypeHint(m_Core);
            else
                m_TexDisplay.typeHint = FormatComponentType.None;

            // if there is no such type or it isn't being followed, use the last seen interpretation
            if (m_TexDisplay.typeHint == FormatComponentType.None && m_TextureSettings.ContainsKey(m_TexDisplay.texid))
                m_TexDisplay.typeHint = m_TextureSettings[m_TexDisplay.texid].typeHint;

            // try to maintain the pan in the new texture. If the new texture
            // is approx an integer multiple of the old texture, just changing
            // the scale will keep everything the same. This is useful for
            // downsample chains and things where you're flipping back and forth
            // between overlapping textures, but even in the non-integer case
            // pan will be kept approximately the same.
            PointF curSize = new PointF((float)CurrentTexture.width, (float)CurrentTexture.height);
            float curArea = curSize.Area();
            float prevArea = m_PrevSize.Area();

            if (prevArea > 0.0f)
            {
                float prevX = m_TexDisplay.offx;
                float prevY = m_TexDisplay.offy;
                float prevScale = m_TexDisplay.scale;

                // allow slight difference in aspect ratio for rounding errors
                // in downscales (e.g. 1680x1050 -> 840x525 -> 420x262 in the
                // last downscale the ratios are 1.6 and 1.603053435).
                if (Math.Abs(curSize.Aspect() - m_PrevSize.Aspect()) < 0.01f)
                {
                    m_TexDisplay.scale *= m_PrevSize.X / curSize.X;
                    CurrentZoomValue = m_TexDisplay.scale;
                }
                else
                {
                    // this scale factor is arbitrary really, only intention is to have
                    // integer scales come out precisely, other 'similar' sizes will be
                    // similar ish
                    float scaleFactor = (float)(Math.Sqrt(curArea) / Math.Sqrt(prevArea));

                    m_TexDisplay.offx = prevX * scaleFactor;
                    m_TexDisplay.offy = prevY * scaleFactor;
                }
            }

            m_PrevSize = curSize;

            // refresh scroll position
            ScrollPosition = ScrollPosition;

            UI_UpdateStatusText();

            mipLevel.Items.Clear();

            m_TexDisplay.mip = 0;
            m_TexDisplay.sliceFace = 0;

            bool usemipsettings = true;
            bool useslicesettings = true;

//.........這裏部分代碼省略.........
開發者ID:Anteru,項目名稱:renderdoc,代碼行數:101,代碼來源:TextureViewer.cs


注:本文中的System.Drawing.PointF.Aspect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。