WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Add background image to the frame (https://www.wowinterface.com/forums/showthread.php?t=46671)

shurshik 06-16-13 08:44 AM

Add background image to the frame
 
Hi!

I need to add an own image to the frame as a background. I have only 1 problem, the image is bigger than frame, example:
frame 300x300
image 600x400

I need to put a part of this image BUT I don't want that other part is visible outside the frame... I already set layer to background, it doesn't help.

Code:

crMapBackground = myframe:CreateTexture(nil,"BACKGROUND")
crMapBackground:SetTexture("Interface\\AddOns\\*\\test_image")
crMapBackground:SetPoint("CENTER",0,0)

how can I make it invisible outside of the frame? Thanks!

Dridzt 06-16-13 09:37 AM

SetTexCoord?

Not sure I understood the question though :p

shurshik 06-16-13 10:05 AM

Yes! Its a little difficult with 4 coord, but I'll try to understand better :)))

Mmmm what is it?
(ULx,ULy,LLx,LLy,URx,URy,LRx,LRy);
Number - point coordinates; top left corner of the image is (0, 0); bottom right corner is (1, 1).

I don't understand why there are 8 params +_+

tried to cut the right part:
/script crMapBackground:SetTexCoord(0,0, 0,0, 0.5,1, 0.5,1)

Dridzt 06-16-13 10:25 AM

Use the simpler form with the 4 numbers (you can think of them as percentage height/width anchored to the top-left)

Code:

0,0---------1,0
|            |
|            |
|            |
0,1---------1,1

SetTexCoord(x1,x2,y1,y2)
first 2 numbers define width, last 2 height.
0,1 = 100% width of original texture.
0,1 = 100% height of original texture.

(0,0.75,0,0.75) = 75% width, 75% height anchored topleft.
(0.25,1,0.25,1) = 75% width, 75% height anchored bottomright.

You get the idea.

For an alternative zork's work using scrollframes for cropping is a trove of information as well.
http://www.wowinterface.com/forums/s...ad.php?t=45918

shurshik 06-16-13 10:32 AM

Perfect!

Thank you very much :)

shurshik 06-16-13 11:56 AM

Spent another 2 hours trying to convert image to tga... Ohhhh.

Tried IrfanView, gimp, ps. Image size 320x320... Hate graphic :(

ravagernl 06-16-13 01:16 PM

Export to 512x512 PNG and convert with http://www.pngconverter.com/

I believe it auto converts alpha opacity to an alpha mask for TGA.

Seerah 06-16-13 02:41 PM

Image files in WoW have 2 requirements:
  1. the dimensions *must* be a power of 2
  2. they have to be in 32-bit .tga or .blp format

shurshik 06-16-13 03:35 PM

The website didn't help me :(

Can't find in gimp where can I change bit format... Found it only in PS6, but changing format can't export it as png/tga :/

Installed some other tools... Ohhh, nothing +_+

Seerah 06-16-13 04:36 PM

When you save as a .tga in PS, it asks you if you want 32-bit or 24-bit, no?

Tonyleila 06-16-13 05:18 PM

Quote:

Originally Posted by shurshik (Post 279727)
The website didn't help me :(

Can't find in gimp where can I change bit format... Found it only in PS6, but changing format can't export it as png/tga :/

Installed some other tools... Ohhh, nothing +_+


Why did you not ask me ingame? I was online with you whole time :D
I have Photoshop so...

Phanx 06-16-13 06:39 PM

Quote:

Originally Posted by shurshik (Post 279727)
Can't find in gimp where can I change bit format... Found it only in PS6, but changing format can't export it as png/tga :/

GIMP's default settings for exporting TGA images are compatible with WoW. You don't need to change anything.

I find it impossible to believe that any version of Photoshop released in the last 20 years doesn't allow you to save/export to PNG or TGA formats...

shurshik 06-17-13 12:54 AM

Hmmm +_+ Ok, thanks :) I'll try it one more time when come back home :) May be I miss something :)))

Upd: oh, not today, tomorrow :)

shurshik 06-18-13 01:51 PM

Found in Photoshop!

The main problem: when I create new image it ask me 8/16/32 bit? If I chose 16 or 32 there is no option to save as tga. 8 bit -> save tga -> ask me if I want 32!

320x320 doesn't work -> 512 yes! Thank you! :)

Result:
http://www.phoenixstyle.com/files/up..._BossRooms.jpg

Digital_Utopia 08-03-13 03:18 AM

Quote:

Originally Posted by shurshik (Post 279907)
Found in Photoshop!

The main problem: when I create new image it ask me 8/16/32 bit? If I chose 16 or 32 there is no option to save as tga. 8 bit -> save tga -> ask me if I want 32!

320x320 doesn't work -> 512 yes! Thank you! :)

Result:
http://www.phoenixstyle.com/files/up..._BossRooms.jpg

You've just gotten yourself confused with the various bits :p

When people are telling you 24 or 32 bit, they're talking 24-32 bits per pixel, from the options dialog that pops up after you click save. the settings you're talking about (under Image -> Mode) give you the choice of 8, 16 and 32 bits per channel. A channel is essentially one of the 3 colors, or the transparency of an image.

So, if you're talking about 32 bits per channel, that would end up being 12-16 bytes per pixel - or 3-4 times the size you need. Most graphics that you're going to be dealing with use nothing more than 8bits per channel, and 24-32 bits per pixel, depending on whether or not your image has transparency.

Malsomnus 08-03-13 03:56 AM

Quote:

Originally Posted by shurshik (Post 279665)
Hi!
Code:

crMapBackground = myframe:CreateTexture(nil,"BACKGROUND")
crMapBackground:SetTexture("Interface\\AddOns\\*\\test_image")
crMapBackground:SetPoint("CENTER",0,0)

how can I make it invisible outside of the frame? Thanks!

I think nobody answered this particular part yet... instead of setting the center point, what I do is:
Code:

crMapBackground:SetAllPoints (myframe)
This way the texture is the exact size and position of your frame (you might actually want to make it smaller if the frame has an edge you want to display). Now it won't be displayed outside the frame and you just have to worry about finding the right coordinates for SetTexCoord.

Also I thought you had to create the texture with:
Code:

crMapBackground = myframe:CreateTexture("Texture","BACKGROUND")
Though if it's been working for you, I guess I'm wrong. Could someone clarify this?

Digital_Utopia 08-03-13 11:15 AM

Quote:

Originally Posted by Malsomnus (Post 282330)
I think nobody answered this particular part yet... instead of setting the center point, what I do is:
Code:

crMapBackground:SetAllPoints (myframe)
This way the texture is the exact size and position of your frame (you might actually want to make it smaller if the frame has an edge you want to display). Now it won't be displayed outside the frame and you just have to worry about finding the right coordinates for SetTexCoord.

Also I thought you had to create the texture with:
Code:

crMapBackground = myframe:CreateTexture("Texture","BACKGROUND")
Though if it's been working for you, I guess I'm wrong. Could someone clarify this?

Nah, you've confused it with creating a new Frame, where you have to specify the type of Frame (Frame, Button, StatusBar, etc.). Since there are only, really, two types of layered regions (Textures, FontStrings) and both have their own, independent way of being created, there's no need to specify.

All you're doing when you type "Texture", in the first field of CreateTexture, is naming that Texture...Texture. The XML equivalent would be:

[code]
<Texture name="Texture">
...
</Texture>
[code]

Malsomnus 08-03-13 11:44 AM

Wow, don't I feel stupid for having created countless textures named Texture ^^
I must have completely misunderstood whichever tutorial I originally saw that on. Thanks for clarifying!

Digital_Utopia 08-03-13 02:29 PM

Quote:

Originally Posted by Malsomnus (Post 282346)
Wow, don't I feel stupid for having created countless textures named Texture ^^
I must have completely misunderstood whichever tutorial I originally saw that on. Thanks for clarifying!

No worries :p

I think we've all done things that seemed to work when we did them, but then realized how absolutely silly it was down the line.

For instance, one of my first addons was using a QR library to generate QR codes for various WoW NPCs/items/chat links. The only problem was, each time a code was generated, my addon created around 1600 new frames, instead of just reusing the existing ones, or (better yet), just reuse 1600 textures in one frame. lol


All times are GMT -6. The time now is 01:09 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI