How to: Display Images in-game

Tutorial By Andrewgosu

Have you ever tried to display images in Warcraft, but, failed miserably?

Of course you have.

Anyway, fear no more!


Follow these easy steps and learn how to display an image of your liking in any Wacraft map!

Requirements

- Photo editing program
- TGA to BLP converter
- Warcraft and World Editor (RoC compatible)
- A little bit patience and time

I'll be using Photo Shop 7 and Wc3 Image Extractor II.

So, lets get started.


Step 1 - Preparing the image for Warcraft

(Image)

Choose a image of your liking - I have chosen this nice James Bond one.

Now, you have two choices:

- crop, scale the image to a power of 2, (e.g) 512x512 px, 256x512 px etc.
- make a new canvas already being a size of power of 2 and copy&paste your image there.

I'll resort to the latter option - I will create a 512x512 px canvas and copy&paste my 300x400 px image there.

(Image)

After that's done, make a selection around the image and open channels.

Add an alpha channel and erase the selected part. That should leave you a pink/red like space around the image.

Or, if you used the first method and scaled your image to right proportions, you should see no red parts.

(Image)

Save the image in 32-bit TGA.


Open the image in a TGA to BLP converter program, Wc3 Image Extractor II, in my case, and convert into .blp.

You have finished preparing the image. Proceed to step 2.


Step 2
- Displaying the image in Warcraft

Right, you got your image ready. It's time to display it.

Open World Editor, and, Import Manager (F12 or "Modulo->Import Manager") and import the previously prepared image to your map.

Now comes the important part, so pay close attention.

The GUI "Create Image" function is "buggy", but I won't go into greater depths. Use the following function, instead:

function CreateImageEx takes string imagePath, real size, real x, real y, real z, boolean showImage returns image
    local image i = CreateImage(imagePath, size, size, 0, x - (size / 2), y - (size / 2), z, 0, 0, 0, 2)
    call SetImageRenderAlways(i, true)
    call ShowImage(i, showImage)
    return i
endfunction


Or, for GUI'ers, a "point" version one (requires the one above, too):

function CreateImageExLoc takes string imagePath, real size, location whichLocation, real z, boolean showImage returns image
    return CreateImageEx(imagePath, size, GetLocationX(whichLocation), GetLocationY(whichLocation), z, showImage)
endfunction


So, copy paste these 2 scripts into your maps header and use a custom script/JASS to display the images.

(Image)

You're all done!

To recap:

- the image must be a power of 2 sized.
- the image must have an alpha layer.
- Use the "CreateImageEx" function to display the image.

(Image)

Got some of my inspiration from this thread, credits.

Feedback is appreciated.

Click here to comment on this tutorial.
 
 
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.