wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > JASS/AI scripts tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 03-24-2006, 07:14 AM   #1
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default How to display Images with Triggers

In this tutorial you'll learn how to properly use the CreateImage native to display images in Warcraft III.
Unfortunately this native is bugged and it can only show very special images correctly, that's why I'm writing my knowledge down.


Background

First let me tell you there are only a few images in the game that can be displayed correctly. So if you want to display
an existing icon you will usually have to modify it a bit and reimport it into your map to get it working.
One of the icons that work is found in UI\Console\Human\human-transport-slot.blp which I happened to use back then for a Minesweeper map I made.
After finding out that this image worked I took a closer look at what made it so special. After a few hours I finally found the solution that I'll explain now.


What to Do

For this tutorial let's suppose you have just made a 64 x 64 icon in Photoshop and you want to display it. Now here is what you'll have to do:
  • Scale it down to X-2 x Y-2, so in our case that's 62 x 62. The reason for this is that we will need an invisible border of 1 pixel on each side.
  • Create a new image with the original size of your image, in our case 64 x 64 with transparent background. Remember image sizes in Warcraft must be power of 2.
  • Copy and paste your image into the new blank image. Now you should have a transparent border around your image.
  • Now make sure you only got the RGB channels and no alpha channel in your image. Then save it as TGA and make sure you save it as 32 bit TGA although you didn't create an alpha channel. This is important to fool Wc3Viewer. This step is optional, it's probably not necessary, but I've never tried using a custom alpha channel - it might or might not work.
  • The TGA can now be converted to BLP with the Wc3Viewer. Download it here if you don't have it yet.
  • Import your image into your map. Use any path you like.
  • When using the CreateImage native just make sure you're using the image type "indicator" (2). Then set the render always property of the image to true and use the ShowImage native to show it. I made the CreateImageEx function below to make it easier for you. The SizeX and SizeY parameters are used to scale the image, you could simply set them to 64 and 64 for a quick test.

Collapse JASS:
function CreateImageEx takes string S, real SizeX, real SizeY, real PosX, real PosY, real PosZ, boolean Show returns image
  local image i = CreateImage(S, SizeX, SizeY, 0, PosX - (SizeX / 2), PosY - (SizeY / 2), PosZ, 0, 0, 0, 2) // image type indicator
  call SetImageRenderAlways(i, true)
  call ShowImage(i, Show)
  return i
endfunction


Conclusion

The key is the transparent border around your image, otherwise it will show ugly black squares around your image when
displaying it in Warcraft III.

I'm also attaching the above-mentioned Minesweeper map in case anyone wants to see it in action. I used images to draw
the numbers in that map as you can see in the attached image.
Minesweeper Download

Zoom (requires log in)

BTW, images are really fast and it's pretty cool that you can change their coloration at runtime.
Unfortunately the z (height) parameter doesn't work very well - the images get clipped wrong, so a height of 0 would
be appropriate in most cases.
Attached Images
File Type: gif minesweeper.gif (39.3 KB, 1716 views)
__________________
Zoom (requires log in)
PitzerMike is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 03-24-2006, 11:29 AM   #2
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

Just a thought, but wouldn't it possibly just be easier to create a small square, flat model and have it with a wackload of animations, each with a different texture to it?

Either way, good tutorial, its strange that they would bug the Image Displays like this, and its always helpful to know little tidbits like this.
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 03-24-2006, 01:26 PM   #3
Fulla
Evil Overlord
 
Fulla's Avatar
 
Join Date: Jan 2006
Posts: 1,416

Submissions (3)

Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)

Default

Id recommend adding a few screenshots, makes a tutorial much better :-)
__________________
Fulla is offline   Reply With Quote
Old 03-26-2006, 02:21 PM   #4
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default

Quote:
Originally Posted by Chuckle_Brother
Just a thought, but wouldn't it possibly just be easier to create a small square, flat model and have it with a wackload of animations, each with a different texture to it?

Yes I think that's possible. But how do you display a certain animation for that model - you'd have to use units or at least destructables, right? Because for special effects you can't set a specific animation. Now that's where the images have their advantage, you don't need units, hence they don't eat CPU power when rendering them. I previously used units in my minesweeper map and as more fields got discovered it would soon get unplayable, with images on the other hand there's no noticeable slowdown.

@Fulla: I agree, I didn't have time to make a screenie before the weekend but now there's a screenshot of that minesweeper map attached.
__________________
Zoom (requires log in)
PitzerMike is offline   Reply With Quote
Old 03-26-2006, 02:32 PM   #5
Blade.dk
.
 
Blade.dk's Avatar


Respected User
 
Join Date: May 2005
Posts: 1,990

Submissions (15)

Blade.dk is a glorious beacon of light (418)Blade.dk is a glorious beacon of light (418)Blade.dk is a glorious beacon of light (418)Blade.dk is a glorious beacon of light (418)Blade.dk is a glorious beacon of light (418)Blade.dk is a glorious beacon of light (418)

Approved Map: Azeroth's Arcane ArenaSpell session 01 winner

Send a message via MSN to Blade.dk
Default

As I've said before, great tutorial.
__________________
Spell Making Course: Part 1: Making a simple stomp spell.
I wonder if I'll ever finish part 2.
Blade.dk is offline   Reply With Quote
Old 10-10-2006, 10:51 AM   #6
Preskooldude
User
 
Preskooldude's Avatar
 
Join Date: Aug 2006
Posts: 47

Preskooldude has little to show at this moment (4)

Send a message via AIM to Preskooldude Send a message via MSN to Preskooldude
Default

Slight question: Could you just create the new image to simply be 2 pixels bigger than the original picture, and skip the scale down by 2 pixels?
Preskooldude is offline   Reply With Quote
Old 10-27-2006, 03:22 PM   #7
Waldbaer
Dragonblood Creator
 
Waldbaer's Avatar
 
Join Date: Nov 2003
Posts: 73

Submissions (3)

Waldbaer will become famous soon enough (37)Waldbaer will become famous soon enough (37)

Default

No because then your picture does not fit the power of 2 size criteria, every BLP must have.
__________________
Waldbaer is offline   Reply With Quote
Old 10-30-2006, 08:05 PM   #8
goble-r1sk
User
 
goble-r1sk's Avatar
 
Join Date: Feb 2006
Posts: 6

goble-r1sk has little to show at this moment (0)

Default

I was playing with displaying an image but had problems. Even after running through this tutorial, my odd glich is still occuring. My image is 128 by 128, no alpha channel, 32bbp, with a 1 pixel transparent border... when I display it looks like this in-game (display size = 128 by 128):
Attached Files
File Type: blp AceClubs.blp (13.1 KB, 21 views)
__________________

Last edited by goble-r1sk : 10-30-2006 at 08:17 PM.
goble-r1sk is offline   Reply With Quote
Old 10-30-2006, 11:06 PM   #9
Waldbaer
Dragonblood Creator
 
Waldbaer's Avatar
 
Join Date: Nov 2003
Posts: 73

Submissions (3)

Waldbaer will become famous soon enough (37)Waldbaer will become famous soon enough (37)

Default

Your picture does not have a transparent border. I don't know why, but for me there isn't any. Please try out the two pictures attached to this post and post your results!
"AceClubs2.blp" is just yours with a 1px transparent border and "AceClubsRound.blp" has rounded edges additionally - this will show us if alpha channel generally works correctly (although I cannot understand why it should not).
Attached Files
File Type: blp AceClubs2.blp (18.1 KB, 33 views)
File Type: blp AceClubsRound.blp (18.2 KB, 30 views)
__________________

Last edited by Waldbaer : 10-30-2006 at 11:08 PM.
Waldbaer is offline   Reply With Quote
Old 10-31-2006, 09:01 PM   #10
goble-r1sk
User
 
goble-r1sk's Avatar
 
Join Date: Feb 2006
Posts: 6

goble-r1sk has little to show at this moment (0)

Default

What program did you use to add the 'transparent' region?

What I discovered to be happening to me in photoschop cs2 was when I saved as 32 bit, pshop automatically added in a full alpha channel, and changed what had been displayed as 'transparent' to white. Possibly what is described in this tutorial is: instead of tricking the program into thinking there is an alpha channel there actually is one, automatically created by the program to block out the 'transparent' area upon save?
If I just custom-alpha out (which I'm used to doing) the 1 pixel border it works fine though : ) Thanks for the help.
__________________

Last edited by goble-r1sk : 10-31-2006 at 09:03 PM.
goble-r1sk is offline   Reply With Quote
Old 11-27-2006, 09:16 PM   #11
Szythe
User
 
Join Date: Sep 2006
Posts: 320

Submissions (3)

Szythe has a spectacular aura about (143)

Spell Making Session 11 WinnerSmiley contest 4th and 5th place.Mapping Contest Third PlaceSpell making session 08

Default

I'm having the exact same problem as goble-r1sk. Whenever I save a file in photoshop (im using 7.0) it changes all of the transparent areas into white areas. Is there any way to change the settings so that it doesn't do this?


EDIT:
after fooling around a while longer, I figured out that the process is slightly different with my version of photoshop. Instead of deleting the alpha map, you have to keep the alpha map. Make the image the full size (64x64 for example) and instead of making it transparent along the border, go to the alpha channel and fill in a 1-pixel border.


Last edited by Szythe : 11-27-2006 at 09:37 PM.
Szythe is offline   Reply With Quote
Old 07-29-2008, 08:00 PM   #12
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

If I click on the icons, will something happen ? Or is this just an image ?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 08-09-2008, 03:42 AM   #13
TriggerHappy
 
Join Date: Feb 2008
Posts: 404

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

you need to use trackables , if you want it to detect where u clicked
TriggerHappy is offline   Reply With Quote
Old 08-11-2008, 09:07 AM   #14
d07.RiV
User
 
d07.RiV's Avatar
 
Join Date: May 2008
Posts: 239

Submissions (1)

d07.RiV is on a distinguished road (10)

Default

I'm not sure you even need the transparent border. You need an alpha channel for sure otherwise it will be all white. Btw I suggest using warcraft 3 viewer.

Also "image type indicator (2)" is not the only one that works. The other one is "image type ubersplat (4)" and its better in some cases because it is affected by fog and lighting, so if you want to add an image onto your terrain (e.g. some logo) you would use this type.
__________________
d07.RiV is offline   Reply With Quote
Old 08-17-2008, 04:46 PM   #15
TEC_Ghost
User
 
TEC_Ghost's Avatar
 
Join Date: Jul 2002
Posts: 416

TEC_Ghost will become famous soon enough (65)TEC_Ghost will become famous soon enough (65)TEC_Ghost will become famous soon enough (65)

Default

I use images in my map and testing with Pyrogasm it seemed to not draw them for Macs, anyone confirm this bug?
__________________

Projects
TEC_Ghost is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:49 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2017, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services