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.

DarkBASIC Discussion / green screen function doesnt work

Author
Message
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 17:43 Edited at: 25th Jun 2009 17:44
WHY DOESNT THIS WORK!?!



all parameters are image numbers

There are only 10 kinds of people in the world, those who understand binary and those who dont
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th Jun 2009 18:08 Edited at: 25th Jun 2009 18:13
You didn't state what it is that you wanted to do, so I revised it based upon what I thought you were trying to accomplish. Here is a revised version:


You make a function call to green_screen, but there is no function in your code at all.

EDIT: I didn't realize this was DBC; try this revised version.


So many games to code......so little time.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 18:22
what im attempting to accomplish was the movie green screen special effect, where the actor(s) stand in front of a large green sheet then during editing the editors replace watevr is visible of the screen with a video or image, so if the editors wanted a beach scene they would just put a beach image on the screen and in the movie the actors would be standing on a beach

so in the program all the green in the green and red image should be getting replaced by the same pixels in the randomized image, thus making the red box be surrounded by randomly colored dots

There are only 10 kinds of people in the world, those who understand binary and those who dont
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th Jun 2009 18:46
I'm not sure if I follow you completely. This code includes the green_screen function, and the red box is surrounded by random colored pixels.


LB


So many games to code......so little time.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Jun 2009 19:02
You don't want to use SET IMAGE COLORKEY to change any color you want to transparent?

That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 20:49 Edited at: 25th Jun 2009 20:50
where is that in the help files?

and LBFN yes that is what I wanted, thanks

There are only 10 kinds of people in the world, those who understand binary and those who dont
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 20:55
scratch that, i didnt see that you messed with my function

what I want is a function that when you input 3 image numbers, it makes memblocks from the first two, then checks each pixel of the first for color

if its green then it copies that same pixel from the SECOND image into the OUTPUT image.

if the pixel ISNT green then it copies that pixel from the FIRST image into the OUTPUT image

I could do this with point instead of memblocks, but hat would be a fair bit slower

There are only 10 kinds of people in the world, those who understand binary and those who dont
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Jun 2009 21:27
Quote: "where is that in the help files?"


Oh sorry... that's in Pro only (forgot where I was apparently).

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Jun 2009 02:33
Quote: "scratch that, i didnt see that you messed with my function"

I never saw your function when I first looked at this, hence my comment,
Quote: "You make a function call to green_screen, but there is no function in your code at all."

so I just made up a function for you.


So many games to code......so little time.
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 26th Jun 2009 08:28 Edited at: 26th Jun 2009 08:32
I always have this problem too. It is saying that your memblock hasn't been created yet. It does this when you make the image inside the program instead of loading it from outside.

What you do to stop to this is sync after you get the image like this:



Here's your fixed code:

I accidentally changed the function into a gosub, while trying to figure out the problem. You can probably figure out how to put it back into one now. If not, I'm always glad to help.



By the way, if an image is created in DB, its normally going to be a 16 bit image, unless you manually change it, but besides that it's going to be 16 bit. So, your getting the pixels for a 16 bit image, you wouldn't use dword, you would use word.

Just saying that, because I also had to change where you were looking for the pixels and using dword, instead of word.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Jun 2009 12:25
Can you not just use paste image with transparency on?
What's different about your code?

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 26th Jun 2009 17:45 Edited at: 26th Jun 2009 17:46
The difference between my code is he used:

get image 1,0,0,10,10

Then he used:

make memblock from image 1,1

If you get an image while in the program and don't sync before you try to make a memblock from the image, then it negates the make memblock command, so you would have to put:

get image 1,0,0,10,10
sync
make memblock from image 1,1

instead of just:

get image 1,0,0,10,10
make memblock from image 1,1
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jun 2009 01:21
@Pictionary
haha sorry I didn't mean YOUR code. I read it, good sync tip
here's what I meant...

@Smartguy
Would pasting an image with transparency produce the effect you are after? If not, how do your requirements differ from the results of this method.

TGC Forum - converting error messages into sarcasm since 2002.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 27th Jun 2009 01:59
its not the effect im after, its the knowledge that im CAPABLE of doing this

There are only 10 kinds of people in the world, those who understand binary and those who dont
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jun 2009 15:29
Okay, am I right in thinking you have a background image that is solid and a foreground image that contains a mask of the colour you want to exclude (blue is the easiest to use)? If this method is faster than pasting an image it could be used to make 2D animations.
Firstly we convert our foreground image to a memblock. Then we need to compare the pixels of the image to our mask colour to see if the pixel should be excluded or copied.

I've left the complicated bits out but my memblock functions can get the pixel colour and draw to a memblock for you, if you don't want to write them yourself that is.
For the moment my functions only work in 32 bit, so make sure you set display mode to that or they wont work properly.

Good Luck

TGC Forum - converting error messages into sarcasm since 2002.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 27th Jun 2009 21:34
isnt 32 bit the default?

There are only 10 kinds of people in the world, those who understand binary and those who dont
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 28th Jun 2009 06:33
I think 16 bit is the default
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 28th Jun 2009 06:34 Edited at: 28th Jun 2009 06:37
that could be the problem, let me test it

edit:
nope

There are only 10 kinds of people in the world, those who understand binary and those who dont
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 28th Jun 2009 06:38
Wait. Are you trying to use your code, or obese's with this.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 28th Jun 2009 06:40
mine preferably, but I want anything that will work as a function that checks each pixel for green and if green takes that pixel from the BACKGROUND image, else takes the FOREGROUND pixel color

There are only 10 kinds of people in the world, those who understand binary and those who dont
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jun 2009 04:57
640,480,16 is the default display mode.

Which image is the green on? Blue is simpler to use btw.
The way I'm thinking is you have blue on the foreground image and the background is solid, then you look through the foreground image to find pixels that aren't blue and paste them to screen or an offscreen bitmap containing the background image.

You should start with the background pasted onto the bitmap you are using and then paste other images on top of it. That way you could have multiple foreground images if you liked.

What are you making this for, or is it just curiosity?

TGC Forum - converting error messages into sarcasm since 2002.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 29th Jun 2009 15:57
Quote: "or is it just curiosity?"

yep

There are only 10 kinds of people in the world, those who understand binary and those who dont

Login to post a reply

Server time is: 2024-05-20 12:37:24
Your offset time is: 2024-05-20 12:37:24