Skip to content

Commit 498cf12

Browse files
committed
feat: add getImageBitmap method
1 parent 64df0e7 commit 498cf12

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/classes/monoBehaviour.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AssetBase } from './base';
55
import type { MonoScript } from './monoScript';
66
import { PPtr } from './pptr';
77
import type { Texture2D } from './texture2d';
8-
import type { ObjectInfo } from './types';
8+
import type { ImgBitMap, ObjectInfo } from './types';
99
import { AssetType } from './types';
1010

1111
class AtlasInfo {
@@ -28,6 +28,16 @@ class AtlasInfo {
2828
if (!img) return;
2929
return getJimpPNG(img);
3030
}
31+
32+
getImageBitmap(): ImgBitMap | undefined {
33+
const bitmap = this.getImageJimp()?.bitmap;
34+
if (!bitmap) return;
35+
return {
36+
data: bitmap.data.buffer as unknown as ArrayBuffer,
37+
width: bitmap.width,
38+
height: bitmap.height,
39+
};
40+
}
3141
}
3242

3343
class AtlasSprite {
@@ -50,6 +60,16 @@ class AtlasSprite {
5060
if (!img) return;
5161
return getJimpPNG(img);
5262
}
63+
64+
getImageBitmap(): ImgBitMap | undefined {
65+
const bitmap = this.getImageJimp()?.bitmap;
66+
if (!bitmap) return;
67+
return {
68+
data: bitmap.data.buffer as unknown as ArrayBuffer,
69+
width: bitmap.width,
70+
height: bitmap.height,
71+
};
72+
}
5373
}
5474

5575
export class MonoBehaviour extends AssetBase {
@@ -97,3 +117,5 @@ export class MonoBehaviour extends AssetBase {
97117
}
98118
}
99119
}
120+
121+
export { AtlasInfo as MonoBehaviourAtlasInfo, AtlasSprite as MonoBehaviourAtlasSprite };

0 commit comments

Comments
 (0)