Page 1 of 1
Export team color images
PostPosted: 02 Sep 2014, 13:25
by paapie
Hi people!
I'm new to the Knight and Merchants forum. I have a little question about exporting images.
How can I change the images with another color as red. So I want for example to export units in yellow or blue.
Some can help? I want to make some simple animations
Greetings Frank
Re: Export team color images
PostPosted: 02 Sep 2014, 13:31
by Krom
Are you exporting from original KaM or from KaM Remake ? Do you know about programming in Pascal/Delphi?
Re: Export team color images
PostPosted: 02 Sep 2014, 13:45
by paapie
I can program in Pascal
but how can I export the images than? The orginal KaM...
Re: Export team color images
PostPosted: 02 Sep 2014, 15:12
by Krom
You can export graphics from original KaM and write a small Pascal tool to replace Reds with other colors, there are just 7 of them
Re: Export team color images
PostPosted: 03 Sep 2014, 09:21
by paapie
Hmm do you have an example source code I know a little bit of Pascal ( know the basics).
Greetz
Re: Export team color images
PostPosted: 03 Sep 2014, 10:53
by Krom
You need to load the BMP and work with its pixels, detecting certain reds and replacing them with other colors.
Your code will go along the lines of:
- Code:
bmp := TBitmap.Create
bmp.LoadFromFile
for width for height do
begin
if bmp.Canvas[x,y] = red_dark then
bmp.Canvas[x,y] := blue_dark;
..
if bmp.Canvas[x,y] = red_light then
bmp.Canvas[x,y] := blue_light;
end;
bmp.SaveToFile
Re: Export team color images
PostPosted: 03 Sep 2014, 11:07
by paapie
Thanks krom!
But red_darker and blue_darker has to be in RGB colors?
Re: Export team color images
PostPosted: 03 Sep 2014, 11:12
by Krom
Yes, alike $122178 - dark red
this will compare only RGB portion of it: if (bmp.Canvas[x,y] and $FFFFFF = $212298) then
You will have to lookup exact values.
Re: Export team color images
PostPosted: 03 Sep 2014, 11:26
by paapie
Thanks for the quick reply krom.
This is my code now:
- Code:
var
bmp: TBitmap;
begin
bmp := TBitmap.Create;
try
bmp.LoadFromFile(file/to/path);
for width for height do
begin
//DARK
if (bmp.Canvas[x,y] and $FFFFFF = $212298) then
bmp.Canvas[x,y] := $122178;
..
//LIGHT
if (bmp.Canvas[x,y] and $FFFFFF = $8788A3)then
bmp.Canvas[x,y] := $000;
end;
bmp.SaveToFile(file/to/path);
finally
bmp.Free;
end;
end;
Re: Export team color images
PostPosted: 03 Sep 2014, 11:39
by Krom
- Code:
for width for height do
will be
- Code:
for y := 0 to bmp.Height - 1 do
for x := 0 to bmp.Width - 1 do
Re: Export team color images
PostPosted: 03 Sep 2014, 11:45
by paapie
Ok I will change the code, did you received my private message? What do you think about it?
Re: Export team color images
PostPosted: 03 Sep 2014, 11:53
by Krom
No, I haven't received anything. You can use email
Re: Export team color images
PostPosted: 03 Sep 2014, 12:11
by paapie
Ok, I have sent you an email what do you think about it?