Beispiel #1
0
        public static void LoadSurfaceFromVolumeSlice(VolumeTexture volumeTex, int mip, int slice, Filter filter, Surface surface)
        {
            VolumeDescription vd         = volumeTex.GetLevelDescription(mip);
            OpsFormatHelper   formatHelp = OpsFormatHelper.FindByFormat(vd.Format);

            Texture sliceTex = new Texture(volumeTex.Device, vd.Width, vd.Height, 1, Usage.None, formatHelp.Format, Pool.SystemMemory);

            Box box = new Box();

            box.Left   = 0;
            box.Right  = vd.Width;
            box.Top    = 0;
            box.Bottom = vd.Height;
            box.Front  = slice;
            box.Back   = slice + 1;

            LockedBox      volumeLB;
            GraphicsStream volumeData = volumeTex.LockBox(0, box, LockFlags.ReadOnly, out volumeLB);

            int            slicePitch;
            GraphicsStream sliceData = sliceTex.LockRectangle(mip, LockFlags.None, out slicePitch);

            CopyTextureData(volumeData, vd.Width, vd.Height, formatHelp, volumeLB.RowPitch, sliceData, slicePitch);

            sliceTex.UnlockRectangle(0);
            volumeTex.UnlockBox(mip);

            SurfaceLoader.FromSurface(surface, sliceTex.GetSurfaceLevel(0), filter, 0);

            sliceTex.Dispose();
        }
Beispiel #2
0
        private static void CopyTextureData(GraphicsStream srcData, int srcWidth, int srcHeight, OpsFormatHelper formatHelp, int srcPitch, GraphicsStream dstData, int dstPitch)
        {
            Byte[] rowData = new Byte[srcWidth * formatHelp.SizeInBytes];
            for (int row = 0; row < srcHeight; row++)
            {
                srcData.Position = row * srcPitch;
                dstData.Position = row * dstPitch;

                srcData.Read(rowData, 0, rowData.Length);
                dstData.Write(rowData, 0, rowData.Length);
            }
        }
        private static void CopyTextureData(GraphicsStream srcData, int srcWidth, int srcHeight, OpsFormatHelper formatHelp, int srcPitch, GraphicsStream dstData, int dstPitch)
        {
            Byte[] rowData = new Byte[srcWidth * formatHelp.SizeInBytes];
            for (int row = 0; row < srcHeight; row++)
            {
                srcData.Position = row * srcPitch;
                dstData.Position = row * dstPitch;

                srcData.Read(rowData, 0, rowData.Length);
                dstData.Write(rowData, 0, rowData.Length);
            }
        }