How to: Display Images in-game

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
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_0001.jpg


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_0002.gif


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_0003.gif


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:

JASS:
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):

JASS:
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_0004.jpg

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_0005.jpg


Got some of my inspiration from this thread, credits.

Feedback is appreciated.
 

Attachments

  • (1)Displaying-Images_Andrewgosu2007.w3x
    86.1 KB · Views: 469

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
woah....nicely made tutorial...+repo :O

edit:
But you might need to explain more on these lines:
Code:
- 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.
i dont know what canvas is...
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Canvas, basically, when you create a new file you create new, empty, canvas.

Power of two: the number two multiplied by itself a certain number of times.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
PitzerMike got it wrong. He adds a transparent layer to the image, which is 1 px wider and taller than the image itself.

An alpha layer should be added, instead, and it doesn't have to be bigger than the image, or something.
 

Black Hawk

New Member
Reaction score
16
Whoa!, this is great Andrewgosu. you can make this awesome ground tile like wood floors. +REP to you.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Submission Rules said:
You must include a prefix so we know what is the submission. If it is a spell, include the [Spell] prefix ([Spellpack] for more than 1 spell). If it is a system, the [System] prefix applies. For code snippets, the prefix is [Snippet], and for tutorials: [Tutorial].

:rolleyes:

Added the prefix already, though.

This is a cool little tutorial, I believe we have nothing like that in the section at that point.

Plus, it helps greatly as displaying an image is buggy using the GUI functions.

Approved!
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
I always forgot to add those prefixes. Bugger.

Sorry for that (in advance, too).
 

trigger_newb

Active Member
Reaction score
3
err this guide is really good but,
you realize that people with the ability to do this, (some) make inappropriate maps, such as maps that shows
porn pics
no offense though...
 
Reaction score
456
You could improve this in few ways.

First of all, editing the image. The image doesn't have to be power of 2, I am currently using 53x54 images for Space Shooter. (In-Game, however, I am creating the in size 81x81). And when creating the image, just create 1px alpha edge for the image, and make sure it's enabled when you save.

Then, it'd be awesome if that CreateImageEx function used width and height instead of size parameter.

Nice anyway. Without this tutorial I'd be completely unable to create images at all :).

EDIT//: Forget what I said about the image sizes. If you want everyone to be able to play your map, make all images power of 2. It was like for 50% my map crashes, and for others it worked fine. Resizing images to power of 2 fixed it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top