2dt Posted February 8, 2014 Share Posted February 8, 2014 The most prominent method for loading textures seems to be the .fromImage functions, which use URLs. What if I have a raw image source, but no URL (like an image generated inside the app). How would I go about making a texture out of that? Quote Link to comment Share on other sites More sharing options...
bubamara Posted February 8, 2014 Share Posted February 8, 2014 Draw that image to canvas and then use .fromCanvasOr use base64 encoded string as source for texture Quote Link to comment Share on other sites More sharing options...
xerver Posted February 8, 2014 Share Posted February 8, 2014 The Texture class is created from a BaseTexture which is created from a texture source (such as an image or canvas). When you do "PIXI.Texture.fromImage('my/url/image.png');" basically what happens is this:var img = new Image();img.src = 'my/url/image.png';var base = new PIXI.BaseTexture(img), texture = new PIXI.Texture(base);// return you the textureIf you already have the image, you can just create a base texture from it and thereby a texture that you can use in your sprites. Hope this helps. Joncom and d13 2 Quote Link to comment Share on other sites More sharing options...
2dt Posted February 8, 2014 Author Share Posted February 8, 2014 Fantastic. Thank you. Quote Link to comment Share on other sites More sharing options...
MichalGo Posted February 28, 2020 Share Posted February 28, 2020 (edited) Hello. Is there a way to do same with ImageBitmap? As I can see currently it is not possible to inject bitmap into BaseTexture as a resource. Edited February 28, 2020 by MichalGo Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 28, 2020 Share Posted February 28, 2020 (edited) 1 hour ago, MichalGo said: Hello. Is there a way to do same with ImageBitmap? As I can see currently it is not possible to inject bitmap into BaseTexture as a resource. Use "new BaseTexture(imageBitmap)" in latest pixi (5.1 or 5.2) . Or directly "new BaseTexture(new PIXI.resources.ImageBitmapResource(imageBitmap))" Edited February 28, 2020 by ivan.popelyshev MichalGo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.