Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
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 or pixel_for_bmap bug? #227554
09/15/08 00:59
09/15/08 00:59
Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
openfire2691 Offline OP
Junior Member
openfire2691  Offline OP
Junior Member

Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
I'm trying to write a script in C-Script that will return the amount of pixels of each color on the screen. For some reason, though, it isn't working. Here's my script:

Code:
 function calculate_colors()
{
	var temp_pixel;
	filehandle = file_open_write ("address.txt"); 
	var format;
	var h = 0;
	var w = 0;
	over_canvas.visible = off;
	wait(2);
	bmap_for_screen(tempy, 1, 0);
	wait(1);
	format = bmap_lock(tempy, 0);
	while(h < bmap_height(tempy))
	{
		while(w < bmap_width(tempy))
		{
			temp_pixel = pixel_to_vec(temp, NULL, format, pixel_for_bmap(tempy, w, h));
			colorpercents[6] += (temp_pixel.green == 75);
			colorpercents[(temp_pixel.red == 255) + ((temp_pixel.green == 255) * 2) + ((temp_pixel.blue == 255) * 4)] += 1;
//Order of colors in array colorpercents is: Other, Red, Green, Yellow, Blue, Purple, Orange, White
			w += 1;
			wait(1);
		}
		w = 0;
		h += 1;
		wait(1);
	}
	over_canvas.visible = on;
	file_var_write(filehandle, colorpercents[0]); //these next few commands write the results of the color scan into an outside document so I can analyze them
	file_var_write(filehandle, colorpercents[1]);
	file_var_write(filehandle, colorpercents[2]);
	file_var_write(filehandle, colorpercents[3]);
	file_var_write(filehandle, colorpercents[4]);
	file_var_write(filehandle, colorpercents[5]);
	file_var_write(filehandle, colorpercents[6]);
	file_var_write(filehandle, colorpercents[7]);
	file_var_write(filehandle, temp_pixel.red); //these three lines write the red, green, and blue values of the last pixel scanned into the same document
	file_var_write(filehandle, temp_pixel.green);
	file_var_write(filehandle, temp_pixel.blue);
	over_canvas.bmap = tempy;
	bmap_unlock(tempy);
	file_close(filehandle);
}


The problem is that the values in temp_pixel are always messed up. The red and green values are always 0, and the blue value changes. For example, it's 63.999 for white, 62 for red, 63.969 for yellow, .030 for blue, and 1.969 for green. Is there some reason for this? I've been going over this script for days and can't find anything wrong. Maybe a bug?


When your script isn't working right, usually it's because it's doing exactly what you told it to. -An Unknown Programmer
Re: pixel_to_vec or pixel_for_bmap bug? [Re: openfire2691] #227556
09/15/08 01:29
09/15/08 01:29
Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
openfire2691 Offline OP
Junior Member
openfire2691  Offline OP
Junior Member

Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
Here's a developement. I was documenting the different values of temp_pixel.blue based on the different colors it was reading, and here were my results:

red = 62;
orange = 63.156;
yellow = 63.969;
green = 1.969;
blue = .030;
purple = 62.030;
white = 63.999;

The interesting thing about these findings is that red, green, and blue have their own set values, while the yellow, purple and white are all just the sum of the red, green, and blue values (ex. red = 62, green = 1.969, yellow = 62 + 1.969 = 63.969). Orange is a little different because I made it 255 red and only 75 green. I don't know what this means, but I thought it might be important.


When your script isn't working right, usually it's because it's doing exactly what you told it to. -An Unknown Programmer

Moderated by  HeelX, rvL_eXile 

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