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,362
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,362
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
08-03-13, 03:56 AM   #7
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   #8
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   #9
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   #10
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


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