---
title: "newTextureViewWithPixelFormat:textureType:levels:slices:"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtltexture/newtextureviewwithpixelformat:texturetype:levels:slices:"
---

# newTextureViewWithPixelFormat:textureType:levels:slices:

Creates a new view of the texture, reinterpreting a subset of its data using a different type and pixel format.

## Declaration

```occ
- (id<MTLTexture>) newTextureViewWithPixelFormat:(MTLPixelFormat) pixelFormat textureType:(MTLTextureType) textureType levels:(NSRange) levelRange slices:(NSRange) sliceRange;
```

## Parameters

- `pixelFormat`: A new pixel format, which needs to be compatible with the original pixel format.
- `textureType`: A new texture type, which can be cast according to the original texture type as listed in the table below.
- `levelRange`: A new base level range that restricts which mipmap levels are visible in the new texture.
- `sliceRange`: A new base slice range that restricts which array slices are visible in the new texture.

## Return Value

Return Value A new texture object that shares the same storage allocation of the calling texture object.

## Discussion

Discussion The texture type can be cast between the targets listed in the following table.  |   |   |   |   |  The length value of the sliceRange parameter needs to be 6 if the new texture type value is MTLTextureType.typeCube, or a multiple of 6 if the new texture type value is MTLTextureType.typeCubeArray. For more information on pixel format restrictions, see makeTextureView(pixelFormat:)

## See Also

### Related Documentation

- [parentRelativeLevel](metal/mtltexture/parentrelativelevel.md)
- [parent](metal/mtltexture/parent.md)
- [parentRelativeSlice](metal/mtltexture/parentrelativeslice.md)

### Creating textures by reinterpreting existing texture data

- [makeTextureView(pixelFormat:)](metal/mtltexture/maketextureview(pixelformat:).md)
- [newTextureViewWithPixelFormat:textureType:levels:slices:swizzle:](metal/mtltexture/newtextureviewwithpixelformat:texturetype:levels:slices:swizzle:.md)
