

- #GIDEROS SET SPRITE OF TEXTURE HOW TO#
- #GIDEROS SET SPRITE OF TEXTURE CODE#
- #GIDEROS SET SPRITE OF TEXTURE DOWNLOAD#
Lets firstly take a look at how we download and create the image: // Download an image file from the webĬIwGameFile* image_file = new CIwGameFile()
#GIDEROS SET SPRITE OF TEXTURE HOW TO#
The new demo shows how to download an image file from the web and create an image from it then display that image as a sprite. Creating an Image from a Web Based Image File Like we did in the previous example, to turn the CIwImage into a CIw2DImage we call Iw2DCreateImage() passing in the CIwImage. Marmalade’s usual create from file style image creation methods do not cover this, so instead we create the image ourselves from the pixel data like so:īasically we create a CIwImage, set its format and dimensions then tell it where our pixel data is using SetOwnedBuffers(). If you look towards the end of our DecompressJPEG() method you will notice that we create our CIwImage / CIw2DImage a slightly different way.īecause we are manually loading and decompressing the pixel data within the JPEG image we are left with a memory buffer containing our raw uncompressed images pixels. In our CIwGameImage::Init() method you will notice that if the image file is a jpeg then we call DecompressJPEG(). How to Create a CIwImage or CIw2DImage from a Pixel Data To turn the CIwImage to a CIw2DImage we call Iw2DCreateImage() passing in the CIwImage. If (!DecompressJPEG((char*)memory_file, memory_file_size))Īs you can see we create a CIwImage by calling CIwImage::ReadFile() passing in the file handle of the memory based file (to find out how to create a file from a memory buffer take a look at CIwGameFile::Open(void* memory_buffer, int memory_buffer_len)). If (file.Open(memory_file, memory_file_size))

Ok, lets take a look how we create an image from a memory based file in the CIwGameImage::Init() method: How to Create a CIwImage or CIw2DImage from a Memory Based File Note that future versions will not rely on is_jpeg and instead, the header data will be checked to determine file type. Is_jpeg – Determines if the memory based image file is a jpeg Memory_file_size – The size of the memory based file

Memory_file – A pointer to the memory based file Name – The name you would like to assign to the file This is very useful if you want to cache the compressed versions of images in memory:īool CIwGameImage::Init(const char* name, void* memory_file, int memory_file_size, bool is_jpeg) The next change to CIwGameImage is the ability to create an image from a file that has already been loaded into memory. Note that this method will create a RGB888 image from the JPEG file, I will add support for conversion to different image pixel formats in a future release. The main method that takes care of JPEG decompression is CIwGameImage::DecompressJPEG().
#GIDEROS SET SPRITE OF TEXTURE CODE#
However, seeing as we have already done the work for it, you may as well just rip the code straight out of IwGameImage.cpp. That said, Marmalade does provide access to LibJPG, allowing you to implement your own JPEG loader. This feature is unfortunately not supported by Marmalades image classes and missing out on JPEG compression for larger images is a bit of a pain. Ok the first change we made was to add the ability to create a CIwGameImage image from a JPEG. Well, this is all possible using the Marmalade SDK and IwGame (wow that sounded a bill salesy!) IwGameImage Changes Imagine your game running completely on dynamic content that lives on a server and you can modify it at any time, Your players will benefit greatly from new fresh content regularly. Whilst that may not be completely practical for some types of games it is for many others. Imagine a situation whereby you can distribute your basic game without having to carry around any of its content, so no graphics, no audio, no level files etc. If you just want the code to this tutorial then download it from here. In this tutorial we are going to go into that a little more as well as show you how to use CIwGameFile and CIwGameImage to download and display images from the web inside your games and apps. We also briefly mentioned that we had updated the CIwGameImage class to support JPEG’s and creation of images from memory based files. We also created a new file class that deals with local and remote file access, allowing us to download files from the web and use them in our game. In our previous tutorial we added the ability to send and receive data to and from a web server. In case you plaw Wow and you’re wondering I have Level 85 Mage, Warlock, Paladin and Druid!

Unfortunately my brother rang me last night and asked me to have a few quick battles with him on World of Warcraft (I just can’t resist PvP) so as it happens, I forgot all about the time and missed publishing my next blog. This tutorial is part of the Marmalade SDK tutorials collection.
