docs: update resources API docs
This commit is contained in:
36
docs/api/resources/texture/getpixeldata.md
Normal file
36
docs/api/resources/texture/getpixeldata.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Texture::GetPixelData
|
||||
|
||||
```cpp
|
||||
const void* GetPixelData() const
|
||||
```
|
||||
|
||||
获取纹理像素数据指针。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 像素数据指针,如果纹理未创建或无效返回 `nullptr`
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 假设已有像素数据
|
||||
std::vector<uint8_t> pixels(1024 * 1024 * 4, 255);
|
||||
|
||||
Texture tex;
|
||||
tex.Create(1024, 1024, 1, 1,
|
||||
TextureType::Texture2D,
|
||||
TextureFormat::RGBA8_UNORM,
|
||||
pixels.data(), pixels.size());
|
||||
|
||||
const void* data = tex.GetPixelData();
|
||||
if (data != nullptr) {
|
||||
// 可以读取像素数据
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Texture 总览](texture.md) - 返回类总览
|
||||
- [GetPixelDataSize](getpixeldatasize.md) - 获取像素数据大小
|
||||
Reference in New Issue
Block a user