Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Nov 2012 16:52
Basically I want to set up clipping regions for images and have them clip. This is easy with sprites thanks to Set Sprite Texture Coord/Size Sprite. But with images we don't have that accessibility. So my question is how could you clip an image that's anything of efficient?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Nov 2012 18:08
Efficient? I would have said use get image, but that's horrifically slow.

Perhaps check into Image Kit, the command ik paste image allows you to crop the image to whatever dimensions you want.

Otherwise you'll have to use memblocks or something.

TheComet

- The codebase
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Nov 2012 20:05
Also, there is the Advanced2d plugin; where you can use a2SetClip x1, y1, x2, y2, to clip the pasting of images, dots, lines, triangles and boxes filled with single colours or gradients.

Although, I'm not sure why you couldn't just use sprites anyway, since you already got them working. Why do you need to clip images?

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Nov 2012 20:53 Edited at: 2nd Nov 2012 22:17
Quote: "the command ik paste image allows you to crop the image to whatever dimensions you want."


It doesn't crop. It stretches

Quote: "where you can use a2SetClip x1, y1, x2, y2, to clip the pasting of images, dots, lines, triangles and boxes filled with single colours or gradients."


Your right... minus images. a2SetClip only works with drawing operations.

The reason I wanted to know was if you could do it directly to images rather than a work around like the method I came up with. Though the sprite based method is actually quite fast. The code needs refining, especially the math for the UV's because there seems to be some float point errors with the division. But I made a safe guard to handle it.

As of uses. GUI components like windows that can be scrolled or scaled to reveal more content. I'm thinking the current method works very well. If you'd like to take a look at it, here it is:

[Edit: Updated v3]


Note: As I said, needs refinement. And seems to be one bug... on it - [Fixed bug]
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Nov 2012 22:41 Edited at: 2nd Nov 2012 22:52
Cool. I also tend to use sprite UVs for speed with UI elements. Did not know a2SetClip does not work with a2DrawImage. But I am assuming the a2D based TopGUI library uses a2SetClip somehow to create its windows; even if you put an image panel in one of its windows.

Hope it goes well.

Edit

Come to think about it, there is another way; the Make Image and Draw To Image commands. Make image of the desired size, then paste onto that one.

GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 2nd Nov 2012 23:06
@Sasuke,

I added something similar to the D3D_Func DLL some time ago. You can find the latest version on the very last post of this thread:

http://forum.thegamecreators.com/?m=forum_view&b=5&t=69221&p=14

Then, use the following:


Once d3d_setviewport is called on a region of the screen, all drawing operations are limited to that region. Or at least they were last time I checked.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Nov 2012 23:08 Edited at: 2nd Nov 2012 23:16
Quote: "Come to think about it, there is another way; the Make Image and Draw To Image commands. Make image of the desired size, then paste onto that one."


Tried that but ended up being to slow.

Your not going to believe this. Mistake on my part! Cause I converted the Help files to the main DBP help files so I could access plugin information through DBP. In the a2 command section, a2DrawImage is not there AHHHH!

Your right it does work. Man! I just wasted an hour... or have a useful but useless snippet seeing as a2 is a tad faster. (Though the Maths for rect intersection will still come in handy for speeding up any method when images are outside the clip zone)

I guess you can only laugh about these things

Cheers guys for the help though

Edit:
GIDustin, Ah sweet! I'll have to check it out. See which is the fastest. Cheers.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Nov 2012 12:13
Great

Login to post a reply

Server time is: 2026-07-10 16:22:13
Your offset time is: 2026-07-10 16:22:13