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 / Cross-dissolve / cross-fade

Author
Message
Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 6th Jun 2005 08:11
I want to dissolve or fade two images into each other, having one fade out while the other fades in. However, I do not think the bitmap fade command can do this. Does anyone know any way that I can? A function that would replace random pixels of one image with random pixels of the other image until it is faded would work too, but can DarkBASIC Classic [Enchanced] do it fast enough?

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 6th Jun 2005 10:02
you could use fade bitmap command
to do the cross fade thing use this

not tested don't blame me

NARUTO IS THE NINJA.......not really
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 6th Jun 2005 12:06
Ocean Runner,

I wanted to write up the code for you, but I unfortunately do not have the time right now. The method I would go about this is to grab the pixel data, by using the point(x,y) command, of each image into a couple of arrays. Let's say you have two images that are 100 X 100 pixels in size. Then, you arrays would need to be 200 slots in size.

Now, with each pixel color saved into their given arrays, compare the pixel data of the first image(the image being faded from), and compare it to the second image(the image being faded into). If the first image's pixel is less than the second, then increase the first's pixel color by 1. If greater, then vice-versa. After each change, then use a couple of for next loops to draw the first image to the screen(the updated pixel data of the fading from image).


+NanoBrain+
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Jun 2005 03:46
Are you sure? The point(x,y) command is very slow...

Immunity and Annihalation makes Immunihalation...
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Jun 2005 04:38 Edited at: 10th Jun 2005 04:38
If you have enhanced, you could do it in memblocks. I assume image memblocks in DBC are the same as Pro:

3 double words - width, height, bit-depth
for 32 bit images, which you will need for the alpha channel, you then have 4 bytes per pixel: blue, green, red, alpha.

So you can manipulate them in memblocks (MAKE MEMBLOCK FROM IMAGE), the fastest way to do a lot of things in DB, then MAKE IMAGE FROM MEMBLOCK.

BatVink
Jake Blues
20
Years of Service
User Offline
Joined: 19th Jun 2004
Location: United States
Posted: 10th Jun 2005 07:11
My program ImageTrans can do exactly what you want to do. Done with memblocks, like BatVink said.

Forum page:
http://forum.thegamecreators.com/?m=forum_view&t=55419&b=5

Download off my site:
http://www.freewebs.com/neodragon64

Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 12th Jun 2005 02:09
Sorry for not responding any sooner, but thanks for your help. Neodragon, when I tried to unzip ImageTrans, it said that there were no files to unzip.

I am going to attempt to code the fade function myself, but I have not any experience with memblocks.

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 12th Jun 2005 04:10
Okay, I have coded a program that looks like it should work, but it tells me that I am trying to access the memblock out of range. The weird thing is that when I replace the variable name with the number that the variable stores, it works! I have checked for misspellings, but have not found any. Can anyone help me?



The code needs two images name 1.jpg and 2.jpg, both 500x300 to work.

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 12th Jun 2005 13:07 Edited at: 12th Jun 2005 13:09
Sorry for the triple post, but I havem an update. I have fixed it, but it runs e...x...t...r...e...m...e...l...y slowly. Does anyone have any ideas on how I can fix that? Also, in the images that I am using [attached], I get this red noise at the bottom. Any ideas?

EDIT: Heh, forgot to attach the code:



"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949

Attachments

Login to view attachments
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 19th Jun 2005 18:11
It's faster than the point() command, but at the end of the day DarkBASIC Classic is an interpreted language. DarkBASIC needs to translate every single freaking command into machine code.

THIS is the kind of stuff where you would just pass the memblock pointer to some DLL somebody nice made for you, and claim the results.

I'd do it, but...unh...

How's my typing? Phone 0800-GO-TO-HELL
Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 22nd Jun 2005 01:35
Well, thanks for everyones help, but it appears that the cross fade is not going to work. So, I am attempting to code a cross-dissolve program, where it replaces random pixels with the pixel it is fading into. The only problem with my code is that for some reason, it exits halfway through it, before it is done, without an error message or anything! Can anyone help?



"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 1st Jul 2005 10:19
Hmm. It appears that after 7,500 operations of the write memblock command, the program crashes. Anyone know why this is or how I can fix it?

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Jul 2005 20:05
Use memblocks and liner interpolate between the two images.

PETA - People for the Eating of Tasty Animals
shadow sliver
20
Years of Service
User Offline
Joined: 28th Nov 2004
Location:
Posted: 2nd Jul 2005 01:07
I'm afraid that I don't understand. What do you mean, and how would I go about doing it?
Ocean Runner
22
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 2nd Jul 2005 01:08
I'm afraid that I don't understand. What does that mean, and how would I go about doing this?

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Jul 2005 01:53
From your code above, it looks like you already know how to get the pixel colors in the images from a memblock.

Interpolate the two images. Match each pixel from image A with image B, like (1,1) or (17,84), then:

New "faded" image = A + (B-A)*k

Where A and B is the color of the pixel at point (x,y) from image A and B. And "k" is between 0 and 1. 0 means you see image A completely. A value of 1 means you seen image B completely. 0.5 would fade half way between the two images.

This link might also help:
http://www.dannywartnaby.co.uk/rgt/index.php?board=4;action=display;threadid=3582

PETA - People for the Eating of Tasty Animals

Login to post a reply

Server time is: 2025-05-22 19:38:35
Your offset time is: 2025-05-22 19:38:35