Thread Tools Display Modes
06-16-13, 08:44 AM   #1
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
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!
  Reply With Quote
06-16-13, 09:37 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
SetTexCoord?

Not sure I understood the question though
  Reply With Quote
06-16-13, 10:05 AM   #3
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
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)
  Reply With Quote
06-16-13, 10:25 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
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

Last edited by Dridzt : 06-16-13 at 07:26 PM.
  Reply With Quote
06-16-13, 10:32 AM   #5
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
Perfect!

Thank you very much
  Reply With Quote
06-16-13, 11:56 AM   #6
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
Spent another 2 hours trying to convert image to tga... Ohhhh.

Tried IrfanView, gimp, ps. Image size 320x320... Hate graphic
  Reply With Quote
06-16-13, 01:16 PM   #7
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Export to 512x512 PNG and convert with http://www.pngconverter.com/

I believe it auto converts alpha opacity to an alpha mask for TGA.
  Reply With Quote
06-16-13, 02:41 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-16-13, 03:35 PM   #9
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
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 +_+

Last edited by shurshik : 06-16-13 at 04:01 PM.
  Reply With Quote
06-16-13, 04:36 PM   #10
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
When you save as a .tga in PS, it asks you if you want 32-bit or 24-bit, no?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-16-13, 05:18 PM   #11
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Originally Posted by shurshik View Post
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
I have Photoshop so...
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
06-16-13, 06:39 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by shurshik View Post
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...
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
06-17-13, 12:54 AM   #13
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
Hmmm +_+ Ok, thanks I'll try it one more time when come back home May be I miss something ))

Upd: oh, not today, tomorrow

Last edited by shurshik : 06-17-13 at 12:43 PM.
  Reply With Quote
06-18-13, 01:51 PM   #14
shurshik
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 31
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
  Reply With Quote
08-03-13, 03:18 AM   #15
Digital_Utopia
A Flamescale Wyrmkin
 
Digital_Utopia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 110
Originally Posted by shurshik View Post
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

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.
__________________
  Reply With Quote
08-03-13, 03:56 AM   #16
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Originally Posted by shurshik View Post
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?
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
08-03-13, 11:15 AM   #17
Digital_Utopia
A Flamescale Wyrmkin
 
Digital_Utopia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 110
Originally Posted by Malsomnus View Post
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]
__________________
  Reply With Quote
08-03-13, 11:44 AM   #18
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
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!
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote
08-03-13, 02:29 PM   #19
Digital_Utopia
A Flamescale Wyrmkin
 
Digital_Utopia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 110
Originally Posted by Malsomnus View Post
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

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
__________________
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Add background image to the frame

Thread Tools
Display Modes

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