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.

Code Snippets / [DBP][+Matrix1Utils] Masking, for scrolling images in none-box areas and the like

Author
Message
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 18th Nov 2010 19:34 Edited at: 18th Nov 2010 19:44
In my course I'm making a HUD with bars (energy, health, etc.) that are, for once, not box shaped. Additionally, I wanted the area of these bars (the "background" of it, that isn't covered by the bar-part itself) to maybe scroll a simple faint pattern or something, maybe even just glow or something (how that factors in here, I am yet to know).

(One other methods I've seen involves covering up the whole screen save for the area you want to see; obviously this isn't suitable for this).

Anyway, using Syncaidius's Memblock Image Manipulation Library, I've come up with a very simple mock/proof of concept (that is, if it's not already been done; a search turned up nothing).

it works by taking two images, one defining the masked area, and the one to display in that area. The RGB of the second is combined with the A of the first to make the desired image.

Animated gif demo (~1mb)

here's the code. It requires two images to work, so they and the code are zipped up and attached to this post. The code itself is a little bit of a mess. Basically, this method is still very slow. Rather than access the memblocks of the source images for every pixel of the output, they're output to an array on loading. That whole thing's a bit rudimentary but I'm looking to make it faster and easier to integrate into thing in the near future.




edit: basic controls: move the mouse to scale the mask (top-left corner for normal size). Switch between files "MaskImageC" and "MaskImageB" for different masks. Also use the mouse to move the image attached to the cursor around; it'll display underneath the effect. Also note, the background pulses colour to show the effect isn't a cutout or such.

further edit: frame rate for me averages around 30, which is yeah-ok, but I reckon it'd slow pretty fast with more or bigger images.

Attachments

Login to view attachments
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 19th Nov 2010 23:40
Quote: "That whole thing's a bit rudimentary but I'm looking to make it faster and easier to integrate into thing in the near future."


If you're trying to make it faster, you might be interested in this plugin.

Especially for the commands:
IK Copy Image Channel Image Number, Channel, Channel Source
IK Paste Image Channel Image Number, Source Image Number, Channel [, Channel Source, X, Y]

or if it's just clipping, you can use:
IK Copy Image Image Number, Source Image Number [, Left, Top, Right, Bottom]


Cheers!
Sven B

MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 21st Nov 2010 17:53
ha, right you are! works like a charm, and fast, so I'll just use that instead. thanks

Login to post a reply

Server time is: 2024-11-21 20:55:57
Your offset time is: 2024-11-21 20:55:57