Introducing external bitmap textures

Introducing external bitmap textures

The Corona engineers have been doing some wonderful things lately, especially on the graphics engine side. One of these items is a feature which allows plugin creators and Corona Enterprise users to push textures directly into the Corona Graphics pipeline, effectively providing bitmap data. Resulting textures will behave similarly to those created by graphics.newTexture().

Below the surface

Normally with Corona display APIs, images are loaded and textures are created in memory, processed via the graphics processing unit (GPU). Once the image is in that realm, it becomes difficult to do pixel-level manipulation — setting and getting individual pixel information is a time-consuming effort, making it impractical for most operations.

Fortunately, the Corona Graphics API set provides capabilities to create textures with custom data from C-based plugins. The resulting objects inherit properties of TextureResourceExternal as well as TextureResource properties. Once created, these objects have filename and baseDir properties which can be used in any display API or for assigning fills.


An example of a plugin which might utilize these capabilities is a plugin which loads SVG (Scalable Vector Graphics) files, rasterizes them on the native C side, and pushes the results to Corona to return a texture object. That texture object could then be used to create typical display objects.

Other examples include image manipulation plugins based on ImageMagick or another C library, custom text and font renderers, and importing images from unsupported formats — the possibilities are endless!

Take it for a test drive!

To demonstrate this technology, our engineers have created a very simple plugin called memoryBitmap. Available in the Corona Marketplace, this plugin has just a single method, memoryBitmap.newTexture(). This creates a blank texture of specified dimensions and the result is a new TextureResourceExternal object with two additional methods: :setPixel() and :getPixel().

Directly “out of the box,” this plugin isn’t particularly useful to Corona SDK developers, since it cannot access your existing images. However, its source code may be useful to Corona Enterprise plugin developers as a template for cross-platform Corona plugins supported on macOS, iOS, tvOS, Android, and Windows.


We made a quick demo to create Spirograph™ style drawings using this new plugin’s :setPixel() method. To test it, you’ll need to activate the plugin in the Corona Marketplace and add the plugin to your build.settings.

memory-bitmapBelow is the code for creating the texture and manipulating it by setting pixels:

In this example, the memoryBitmap.newTexture() function is returning a blank slate to work with. Essentially, you tell it the size of the object and the color depth rules and then you can start manipulating pixels as much as you like.


We are excited to see what enterprising Corona developers will create with TextureResourceExternal and the memoryBitmap plugin as a basis for amazing features. Got a great idea? Please join us in the Corona forums!

Rob Miracle

Rob is the Developer Relations Manager for Corona Labs. Besides being passionate about helping other developers make great games using Corona, he is also enjoys making games in his spare time. Rob has been coding games since 1979 from personal computers to mainframes. He has over 16 years professional experience in the gaming industry.

No Comments

Sorry, the comment form is closed at this time.