/// <summary>
 /// Draw a texture.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="nw"></param>
 /// <param name="nh"></param>
 /// <param name="uoff"></param>
 /// <param name="voff"></param>
 /// <param name="umax"></param>
 /// <param name="vmax"></param>
 /// <param name="color"></param>
 public void Draw(float x, float y, float nw, float nh, float uoff,
                  float voff, float umax, float vmax, uint color)
 {
     if (_textureNumber >= 0)
     {
         float[,] matrix = GUIGraphicsContext.GetFinalMatrix();
         DXNative.FontEngineDrawTextureSync(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax, color, matrix);
     }
 }
 /// <summary>
 /// Draw a masked texture.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="nw"></param>
 /// <param name="nh"></param>
 /// <param name="uoff"></param>
 /// <param name="voff"></param>
 /// <param name="umax"></param>
 /// <param name="vmax"></param>
 /// <param name="color"></param>
 /// <param name="maskTextureNo"></param>
 /// <param name="uoffm"></param>
 /// <param name="voffm"></param>
 /// <param name="umaxm"></param>
 /// <param name="vmaxm"></param>
 public void DrawMasked(float x, float y, float nw, float nh, float uoff, float voff, float umax, float vmax,
                        uint color, int maskTextureNo, float uoffm, float voffm, float umaxm, float vmaxm)
 {
     if (_textureNumber >= 0)
     {
         float[,] matrix = GUIGraphicsContext.GetFinalMatrix();
         DXNative.FontEngineDrawMaskedTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax,
                                              color, matrix, maskTextureNo, uoffm, voffm, umaxm, vmaxm);
     }
 }
        /// <summary>
        /// Draw a texture rotated around (x,y).
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="nw"></param>
        /// <param name="nh"></param>
        /// <param name="zrot"></param>
        /// <param name="uoff"></param>
        /// <param name="voff"></param>
        /// <param name="umax"></param>
        /// <param name="vmax"></param>
        /// <param name="color"></param>
        public void Draw(float x, float y, float nw, float nh, float zrot, float uoff,
                         float voff, float umax, float vmax, uint color)
        {
            if (_textureNumber >= 0)
            {
                // Rotate around the x,y point of the specified rectangle; maintain aspect ratio (1.0f)
                TransformMatrix localTransform = new TransformMatrix();
                localTransform.SetZRotation(zrot, x, y, 1.0f);
                TransformMatrix finalTransform = GUIGraphicsContext.GetFinalTransform();
                localTransform = finalTransform.multiply(localTransform);

                DXNative.FontEngineDrawTextureSync(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax, color,
                                                   localTransform.Matrix);
            }
        }
        private void DisposeUnmanagedResources()
        {
            if (_textureNumber >= 0)
            {
                DXNative.FontEngineRemoveTextureSync(_textureNumber);
                _textureNumber = -1;
            }

            if (_image != null && !_image.Disposed)
            {
                _image.Disposing -= new EventHandler(D3DTexture_Disposing);
                _image.SafeDispose();
            }

            _image = null;
        }
        public TextureFrame(string name, Texture image, int duration)
        {
            _imageName = name;
            _image     = image;
            _duration  = duration;

            if (image != null)
            {
                unsafe
                {
                    _image.Disposing -= new EventHandler(D3DTexture_Disposing);
                    _image.Disposing += new EventHandler(D3DTexture_Disposing);

                    IntPtr ptr = DirectShowUtil.GetUnmanagedTexture(_image);
                    _textureNumber = DXNative.FontEngineAddTextureSync(ptr.ToInt32(), true, (void *)ptr.ToPointer());
                }
            }
        }
Example #6
0
        public void Render()
        {
            lock (_OSDLock)
            {
                // Store current settings so they can be restored when we are done
                VertexFormats vertexFormat = GUIGraphicsContext.DX9Device.VertexFormat;

                try
                {
                    if (_OSDTexture == null || _OSDTexture.Disposed)
                    {
                        return;
                    }

                    int wx = 0, wy = 0, wwidth = 0, wheight = 0;
                    if (GUIGraphicsContext.IsFullScreenVideo)
                    {
                        wheight = PlaneScene.DestRect.Height;
                        wwidth  = PlaneScene.DestRect.Width;

                        wx = GUIGraphicsContext.OverScanLeft;
                        wy = GUIGraphicsContext.OverScanTop;

                        if (PlaneScene.DestRect.X == 0 || PlaneScene.DestRect.Y == 0)
                        {
                            wx += PlaneScene.DestRect.X;
                            wy += PlaneScene.DestRect.Y;
                        }
                    }
                    else // Video overlay
                    {
                        wheight = GUIGraphicsContext.VideoWindow.Height;
                        wwidth  = GUIGraphicsContext.VideoWindow.Width;

                        wx = GUIGraphicsContext.VideoWindow.Right - (GUIGraphicsContext.VideoWindow.Width);
                        wy = GUIGraphicsContext.VideoWindow.Top;
                    }

                    DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHABLENDENABLE, 1);
                    CreateVertexBuffer(wx, wy, wwidth, wheight);

                    // Make sure D3D objects haven't been disposed for some reason. This would cause
                    // an access violation on native side, causing Skin Engine to halt rendering
                    if (!_OSDTexture.Disposed && !_vertexBuffer.Disposed)
                    {
                        GUIGraphicsContext.DX9Device.SetStreamSource(0, _vertexBuffer, 0);
                        GUIGraphicsContext.DX9Device.SetTexture(0, _OSDTexture);
                        GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedTextured.Format;
                        GUIGraphicsContext.DX9Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    }
                    else
                    {
                        Log.Debug("OSD renderer: D3D resource was disposed! Not trying to render the texture");
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }

                try
                {
                    // Restore device settings
                    GUIGraphicsContext.DX9Device.SetTexture(0, null);
                    GUIGraphicsContext.DX9Device.VertexFormat = vertexFormat;
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
        public void Render()
        {
            if (_player == null)
            {
                return;
            }

            lock (_subtitleLock)
            {
                if (_clearOnNextRender)
                {
                    //Log.Debug("SubtitleRenderer: clearOnNextRender");
                    _clearOnNextRender = false;
                    if (_subTexture != null)
                    {
                        _subTexture.SafeDispose();
                    }
                    _subTexture      = null;
                    _currentSubtitle = null;
                }

                if (_renderSubtitles == false)
                {
                    return;
                }

                // ugly temp!
                bool timeForNext = false;
                if (_subtitles.Count > 0)
                {
                    Subtitle next = _subtitles.First.Value;
                    if (next.presentTime <= _player.StreamPosition)
                    {
                        timeForNext = true;
                    }
                }

                _posOnLastRender = _player.StreamPosition;

                // Check for subtitle if we dont have one currently or if the current one is beyond its timeout
                if (_currentSubtitle == null ||
                    _currentSubtitle.presentTime + _currentSubtitle.timeOut <= _player.StreamPosition ||
                    timeForNext)
                {
                    //Log.Debug("-Current position: ");
                    if (_currentSubtitle != null && !timeForNext)
                    {
                        //Log.Debug("-Current subtitle : " + currentSubtitle.ToString() + " time out expired");
                        _currentSubtitle = null;
                    }
                    if (timeForNext)
                    {
                        //if (currentSubtitle != null) Log.Debug("-Current subtitle : " + currentSubtitle.ToString() + " TIME FOR NEXT!");
                    }

                    Subtitle next = null;
                    while (_subtitles.Count > 0)
                    {
                        next = _subtitles.First.Value;

                        //Log.Debug("-next from queue: " + next.ToString());
                        // if the next should be displayed now or previously
                        if (next.presentTime <= _player.StreamPosition)
                        {
                            // remove from queue
                            _subtitles.RemoveFirst();

                            // if it is not too late for this sub to be displayed, break
                            // otherwise continue
                            if (next.presentTime + next.timeOut >= _player.StreamPosition)
                            {
                                _currentSubtitle = next;
                                break;
                            }
                        }
                        // next wants to be displayed in the future so break
                        else
                        {
                            //Log.Debug("-next is in the future");
                            break;
                        }
                    }
                    // if currentSubtitle is non-null we have a new subtitle
                    if (_currentSubtitle != null)
                    {
                        SetSubtitle(_currentSubtitle);
                    }
                    else
                    {
                        return;
                    }
                }

                VertexFormats vertexFormat = GUIGraphicsContext.DX9Device.VertexFormat;

                try
                {
                    int   wx = 0, wy = 0, wwidth = 0, wheight = 0;
                    float rationW = 1, rationH = 1;

                    Rectangle src, dst;
                    VMR9Util.g_vmr9.GetVideoWindows(out src, out dst);

                    rationH = dst.Height / (float)_currentSubtitle.screenHeight;
                    rationW = dst.Width / (float)_currentSubtitle.screenWidth;
                    wx      = dst.X + (int)(rationW * (float)_currentSubtitle.horizontalPosition);
                    wy      = dst.Y + (int)(rationH * (float)_currentSubtitle.firstScanLine);
                    wwidth  = (int)((float)_currentSubtitle.width * rationW);
                    wheight = (int)((float)_currentSubtitle.height * rationH);

                    // make sure the vertex buffer is ready and correct for the coordinates
                    CreateVertexBuffer(wx, wy, wwidth, wheight);

                    // Log.Debug("Subtitle render target: wx = {0} wy = {1} ww = {2} wh = {3}", wx, wy, wwidth, wheight);

                    // enable alpha blending so that the subtitle is rendered with transparent background
                    DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHABLENDENABLE, 1);

                    // Make sure D3D objects haven't been disposed for some reason. This would  cause
                    // an access violation on native side, causing Skin Engine to halt rendering
                    if (!_subTexture.Disposed && !_vertexBuffer.Disposed)
                    {
                        GUIGraphicsContext.DX9Device.SetStreamSource(0, _vertexBuffer, 0);
                        GUIGraphicsContext.DX9Device.SetTexture(0, _subTexture);
                        GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedTextured.Format;
                        GUIGraphicsContext.DX9Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                    }
                    else
                    {
                        Log.Debug("Subtitle renderer: D3D resource was disposed! Not trying to render the texture");
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }

                try
                {
                    // Restore device settings
                    GUIGraphicsContext.DX9Device.SetTexture(0, null);
                    GUIGraphicsContext.DX9Device.VertexFormat = vertexFormat;
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            } // end of lock (subtitle)
        }
Example #8
0
        /// <summary>
        /// render the image contained in texture onscreen
        /// </summary>
        /// <param name="texture">Directx texture containing the image</param>
        /// <param name="x">x (left) coordinate</param>
        /// <param name="y">y (top) coordinate</param>
        /// <param name="nw">width </param>
        /// <param name="nh">height</param>
        /// <param name="iTextureWidth">width in texture</param>
        /// <param name="iTextureHeight">height in texture</param>
        /// <param name="iTextureLeft">x (left) offset in texture</param>
        /// <param name="iTextureTop">y (top) offset in texture</param>
        /// <param name="lColorDiffuse">diffuse color</param>
        //public static void RenderImage(ref Texture texture, float x, float y, float nw, float nh, float iTextureWidth, float iTextureHeight, float iTextureLeft, float iTextureTop, long lColorDiffuse)
        public static void RenderImage(Texture texture, float x, float y, float nw, float nh, float iTextureWidth,
                                       float iTextureHeight, float iTextureLeft, float iTextureTop, long lColorDiffuse)
        {
            if (texture == null)
            {
                return;
            }
            if (texture.Disposed)
            {
                return;
            }
            if (GUIGraphicsContext.DX9Device == null)
            {
                return;
            }
            if (GUIGraphicsContext.DX9Device.Disposed)
            {
                return;
            }

            if (x < 0 || y < 0)
            {
                return;
            }
            if (nw < 0 || nh < 0)
            {
                return;
            }
            if (iTextureWidth < 0 || iTextureHeight < 0)
            {
                return;
            }
            if (iTextureLeft < 0 || iTextureTop < 0)
            {
                return;
            }

            VertexBuffer m_vbBuffer = null;

            try
            {
                m_vbBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColoredTextured),
                                              4, GUIGraphicsContext.DX9Device,
                                              0, CustomVertex.TransformedColoredTextured.Format,
                                              GUIGraphicsContext.GetTexturePoolType());

                Direct3D.SurfaceDescription desc;
                desc = texture.GetLevelDescription(0);

                float uoffs = ((float)iTextureLeft) / ((float)desc.Width);
                float voffs = ((float)iTextureTop) / ((float)desc.Height);
                float umax  = ((float)iTextureWidth) / ((float)desc.Width);
                float vmax  = ((float)iTextureHeight) / ((float)desc.Height);

                if (uoffs < 0 || uoffs > 1)
                {
                    return;
                }
                if (voffs < 0 || voffs > 1)
                {
                    return;
                }
                if (umax < 0 || umax > 1)
                {
                    return;
                }
                if (vmax < 0 || vmax > 1)
                {
                    return;
                }
                if (umax + uoffs < 0 || umax + uoffs > 1)
                {
                    return;
                }
                if (vmax + voffs < 0 || vmax + voffs > 1)
                {
                    return;
                }
                if (x < 0)
                {
                    x = 0;
                }
                if (x > GUIGraphicsContext.Width)
                {
                    x = GUIGraphicsContext.Width;
                }
                if (y < 0)
                {
                    y = 0;
                }
                if (y > GUIGraphicsContext.Height)
                {
                    y = GUIGraphicsContext.Height;
                }
                if (nw < 0)
                {
                    nw = 0;
                }
                if (nh < 0)
                {
                    nh = 0;
                }
                if (x + nw > GUIGraphicsContext.Width)
                {
                    nw = GUIGraphicsContext.Width - x;
                }
                if (y + nh > GUIGraphicsContext.Height)
                {
                    nh = GUIGraphicsContext.Height - y;
                }

                CustomVertex.TransformedColoredTextured[] verts =
                    (CustomVertex.TransformedColoredTextured[])m_vbBuffer.Lock(0, 0);
                // Lock the buffer (which will return our structs)
                verts[0].X     = x - 0.5f;
                verts[0].Y     = y + nh - 0.5f;
                verts[0].Z     = 0.0f;
                verts[0].Rhw   = 1.0f;
                verts[0].Color = (int)lColorDiffuse;
                verts[0].Tu    = uoffs;
                verts[0].Tv    = voffs + vmax;

                verts[1].X     = x - 0.5f;
                verts[1].Y     = y - 0.5f;
                verts[1].Z     = 0.0f;
                verts[1].Rhw   = 1.0f;
                verts[1].Color = (int)lColorDiffuse;
                verts[1].Tu    = uoffs;
                verts[1].Tv    = voffs;

                verts[2].X     = x + nw - 0.5f;
                verts[2].Y     = y + nh - 0.5f;
                verts[2].Z     = 0.0f;
                verts[2].Rhw   = 1.0f;
                verts[2].Color = (int)lColorDiffuse;
                verts[2].Tu    = uoffs + umax;
                verts[2].Tv    = voffs + vmax;

                verts[3].X     = x + nw - 0.5f;
                verts[3].Y     = y - 0.5f;
                verts[3].Z     = 0.0f;
                verts[3].Rhw   = 1.0f;
                verts[3].Color = (int)lColorDiffuse;
                verts[3].Tu    = uoffs + umax;
                verts[3].Tv    = voffs;


                m_vbBuffer.Unlock();

                GUIGraphicsContext.DX9Device.SetTexture(0, texture);

                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);


                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);

                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);

                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
                DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);

                DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);
                DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);

                int   g_nAnisotropy    = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
                float g_fMipMapLodBias = 0.0f;

                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);

                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
                DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);

                // Render the image
                GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
                GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
                GUIGraphicsContext.DX9Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);

                // unset the texture and palette or the texture caching crashes because the runtime still has a reference
                GUIGraphicsContext.DX9Device.SetTexture(0, null);
            }
            finally
            {
                if (m_vbBuffer != null)
                {
                    m_vbBuffer.SafeDispose();
                }
            }
        }
Example #9
0
        private void DrawTexture(uint texAddr, long lColorDiffuse)
        {
            if (texAddr == 0)
            {
                return;
            }
            unsafe
            {
                IntPtr ptr = new IntPtr(texAddr);
                DXNative.FontEngineSetTexture(ptr.ToPointer());

                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_ADDRESSU, (int)D3DTEXTUREADDRESS.D3DTADDRESS_CLAMP);
                DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_ADDRESSV, (int)D3DTEXTUREADDRESS.D3DTADDRESS_CLAMP);

                GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;

                DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHABLENDENABLE, 0);

                if (_useNonLinearStretch)
                {
                    //draw/stretch each partition separately according to NLS table

                    //top and bottom remain untouched.
                    //left and right start from the left of the rect.
                    int   srcLeft       = _sourceRect.Left;
                    float srcLeftFloat  = (float)_sourceRect.Left;
                    int   srcRight      = srcLeft;
                    float srcRightFloat = (float)srcLeft;
                    int   dstLeft       = _destinationRect.Left;
                    float dstLeftFloat  = _destinationRect.Left;
                    int   dstRight      = dstLeft;
                    float dstRightFloat = (float)dstLeft;
                    for (int i = 0; i < nlsSourcePartitioning.Length; i++)
                    {
                        //this left is the previous right
                        srcLeft      = srcRight;
                        dstLeft      = dstRight;
                        srcLeftFloat = srcRightFloat;
                        dstLeftFloat = dstRightFloat;

                        //calculate new right
                        srcRightFloat = srcLeftFloat + (int)(nlsSourcePartitioning[i] * (float)_sourceRect.Width / 100.0f);
                        dstRightFloat = dstLeftFloat + (int)(nlsDestPartitioning[i] * (float)_destinationRect.Width / 100.0f);
                        srcRight      = (int)srcRightFloat;
                        dstRight      = (int)dstRightFloat;


                        DrawTextureSegment(_vertexBuffers[i],
                                           srcLeft,
                                           _sourceRect.Top,
                                           srcRight - srcLeft,
                                           _sourceRect.Height,
                                           dstLeft,
                                           _destinationRect.Top,
                                           dstRight - dstLeft,
                                           _destinationRect.Height,
                                           lColorDiffuse);
                    }
                }
                else
                {
                    DrawTextureSegment(_vertexBuffers[0],
                                       _sourceRect.Left,
                                       _sourceRect.Top,
                                       _sourceRect.Width,
                                       _sourceRect.Height,
                                       _destinationRect.Left,
                                       _destinationRect.Top,
                                       _destinationRect.Width,
                                       _destinationRect.Height,
                                       lColorDiffuse);
                }

                // unset the texture and palette or the texture caching crashes because the runtime still has a reference
                GUIGraphicsContext.DX9Device.SetTexture(0, null);
            }
        }