Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2001:
[Freeciv-Dev] Re: flag scaling problem
Home

[Freeciv-Dev] Re: flag scaling problem

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Karl-Ingo Friese <kif@xxxxxxxxxxxxxxxxxxxxxxxxxx>, <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: flag scaling problem
From: Thue <thue@xxxxxxx>
Date: Sat, 16 Jun 2001 16:21:47 +0200

On Saturday 16 June 2001 14:57, Karl-Ingo Friese wrote:
> Hello again,
>
> I am currently trying to enhance the player report again, based on a
>
> suggestion by Peter Barker:
> > The feature I was going to work on next was adding a "Flag" column to
> > this dialogue. Primary reason is that last lan-game we had, people were
> > having trouble remembering which flag was which since they only had two
> > mouse buttons.
> >
> > I don't suppose while you're hacking that code you'd care to add
> > it?
>
> The idea sounded good, so I implemented it. A first picture of this can be
> found at:
>
>    www-c.informatik.uni-hannover.de/~kif/civ/plrs4.jpg
>
> Now I have the following problem: I had to scale the flag pixmaps to fit
> into the rows (row heigh depends on the font using to display the
> playerinfos). I did this by using the gtk_scale_pixmap() function from
> client/gui-gtk/gui_stuff.h.
>
> So far so good. The problem is, that the original flag pixmaps contains
> not only the flag image, but "unused" pixels, because the flag pixmap
> dimensions seem to be related to the tileset dimensions. To get a proper
> image, I would need to find out the dimensions of the "real" flag. Even
> better, create an original-flag-pixmap first, containing only the
> flag-image itself, and scaling it later. Right now, the unused pixels are
> scaled as well, resulting in a black border and very small flag picture.
>
> What I am doing right now is:
>
> void build_flag(int playerindex) {
>   double oldh, oldw, flagh, flagw;
>
>   oldw=get_nation_by_idx(playerindex)->flag_sprite->width;
>   oldh=get_nation_by_idx(playerindex)->flag_sprite->height;
>
>   flagh=GTK_CLIST(players_list)->row_height;
>   flagw=(flagh/oldh)*oldw;
>
>   flags[playerindex]=gtk_scale_pixmap(
>     get_nation_by_plr(&game.players[playerindex])->flag_sprite->pixmap,
>     oldw, oldh,
>     flagw, flagh);
> }
>
> Help would be very much appreciated!
> ChaosE
>
> PS: Please reply to me directly, since I am not on the developers mailing
>     list yet.

You could change the flag spec files so that the real flag sizes were listed, 
and used when the flags were loaded. I think the rest of the drawing 
algoritms would work fine even if the flags were trimmed, since the flags 
always start at the top left corner.
Since the flags are different sizes you would have to specify the flag sizes 
per flag; a bit ugly.

Alternatively, you could examine the pixels in a loaded flag (or when it was 
first loaded), and automatically cut it down. Just look how far to the 
right/buttom the transparent pixels start.

Or my favorite solution: make the transparent pixels work. If they were white 
like the background it would look fine in your dialog.
If you scaled on a per-flag basis the relative sizes of the flags would be 
different from the main map. I think that wouldn't look good.
Note that the flags seem to come in all heights and widths.

-Thue


[Prev in Thread] Current Thread [Next in Thread]