Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
pixel_to_vec returns wrong color #188770
03/16/08 15:26
03/16/08 15:26
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
hello,
I played around with pixel_to_vec a bit and I found out, that I alwas returns 0 at the blue chanel, red and green behave normally.

This lines(in a loop) for example give me a yellow picture:

Code:
vec_set(pixelColor,vector(255,255,255));
pixel = pixel_for_vec(pixelColor,100,format);
pixel_to_bmap(outputBMP,x,y,pixel);



Cheers
Scorpion

Re: pixel_to_vec returns wrong color [Re: Scorpion] #188771
03/16/08 17:39
03/16/08 17:39
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yellow is blue plus green. Getting a yellow image with 0 in the blue channel is physically impossible.

The most frequent mistake of people trying to write into a bitmap is using a wrong format.

Re: pixel_to_vec returns wrong color [Re: jcl] #188772
03/16/08 19:40
03/16/08 19:40
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
yellow is red + green..sorry to disappoint you there lol^^



edit: i checked the format it's 8888....the target and the destination bmap

Last edited by Scorpion; 03/16/08 20:03.
Re: pixel_to_vec returns wrong color [Re: Scorpion] #188773
03/16/08 23:53
03/16/08 23:53
Joined: Aug 2005
Posts: 312
Sweden
tindust Offline
Senior Member
tindust  Offline
Senior Member

Joined: Aug 2005
Posts: 312
Sweden
It's been a while since I worked with this, but it has to do with the order in which the colors are listed in the vector. For bitmap it is red-green-blue so using vec_set then you need to begin the vector with red, for example vec_set(colorvector.x,your.red). But when accessing or setting the color vector of a pixel, the color order is blue-green-red. The vector is then set through colorvector.blue. A conversion step from bmap vector to pixelvector is needed otherwise you "loose" a color which you seem to have done since the vector used begins with the second color. The last color value, the lost one, is set to zero. It took a while before I realized what was going on when working with this.

Hope this makes sense.

cheers,

Re: pixel_to_vec returns wrong color [Re: tindust] #188774
03/17/08 00:01
03/17/08 00:01
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
as you can see i set the vector to 255,255,255 so the order isn't important

Re: pixel_to_vec returns wrong color [Re: Scorpion] #188775
03/17/08 09:55
03/17/08 09:55
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You're right with the red plus green. But I can still not confirm your problem.

pixel_to_vec is a frequently used function, but we haven't heard that any other user had problems with it so far. Check the the format with bmap_lock. Make sure that it's really 8888 and not 888, which would explain your problem.

If you can't find the problem this way, please send a test project to the support. We'll check.

Re: pixel_to_vec returns wrong color [Re: jcl] #188776
03/18/08 13:28
03/18/08 13:28
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
The reason for your problem is a wrong type of your pixel parameter. You used int but the function expects var. Converting var to int loses the fractional part of the number, which in turn leads to wrong colors.

You can find a description of the difference of int and var in the manual under "Variables".

Re: pixel_to_vec returns wrong color [Re: jcl] #188777
03/19/08 14:20
03/19/08 14:20
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
hm ok, thank you. I didn'T noticed that I defined it as int.
Controled everything, but the type of the variable X/


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1