EU4RevFlagRenderer.cs
usingSystem; |
usingSystem.Collections.Generic; |
usingSystem.Drawing; |
usingSystem.Drawing.Imaging; |
usingSystem.IO; |
usingMeaster; |
namespaceConsoleTestApp |
{ |
internalclassEU4RevFlagRenderer |
{ |
privateList<SolidBrush> m_flagColors=newList<SolidBrush>(); |
privateBitmapm_shieldMask, m_shieldFrame; |
privateFontm_nameFont; |
privateconstintCOLUMN_WIDTH=30; |
privateconstintFLAG_X_OFFSET=27; |
publicvoidRun() |
{ |
GetColors(); |
m_shieldFrame=newBitmap( 'topbar_big_frame.png' ); |
m_shieldMask=newBitmap( 'shield_fancy_mask.png' ); |
m_nameFont=newFont( FontFamily.GenericSansSerif, 8 ); |
DrawCountryFlags(); |
} |
privatevoidDrawCountryFlags() |
{ |
FileInfo[] files= ( newDirectoryInfo( @'C:SteamGamesSteamAppscommonEuropa Universalis IVcommoncountries' ) ).GetFiles( '*.txt' ); |
foreach( FileInfocountryinfiles ) |
{ |
using( StreamReadersr=newStreamReader( country.FullName ) ) |
{ |
stringline; |
while( ( line=sr.ReadLine() ) !=null ) |
{ |
if( !line.StartsWith( 'revolutionary_colors' ) ) |
continue; |
string[] parts=line.Split( '{', '}' )[1].Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries ); |
using( Bitmapflg=DrawColours( int.Parse( parts[0] ), int.Parse( parts[1] ), int.Parse( parts[2] ) ) ) |
{ |
AddFrame( flg, country.Name.Split( '.' )[0] ); |
flg.Save( 'flags/'+country.Name.Split( '.' )[0] +'.png', ImageFormat.Png ); |
} |
break; |
} |
} |
} |
} |
privatevoidAddFrame( Bitmapflg, stringname ) |
{ |
using( UnsafeBitmapmask=newUnsafeBitmap( m_shieldMask ) ) |
using( UnsafeBitmapflag=newUnsafeBitmap( flg ) ) |
{ |
UnsafeColorbackground=newUnsafeColor( 255, 35, 35, 35 ); |
for( inty=0; y<181; y++ ) |
{ |
for( intx=0; x<145; x++ ) |
{ |
if( y>160 ) |
{ |
flag.SetPixel( x, y, background ); |
continue; |
} |
varmaskCol=mask.GetPixel( x, y ); |
if( maskCol.Red0 ) |
flag.SetPixel( x, y, background ); |
} |
} |
} |
using( Graphicsg=Graphics.FromImage( flg ) ) |
{ |
g.DrawImage( m_shieldFrame, 0, 0, 145, 161 ); |
g.DrawString( name, m_nameFont, m_flagColors[0], 8, 162 ); |
} |
} |
privateBitmapDrawColours( intleft, intcentre, intright ) |
{ |
Bitmapb=newBitmap( 145, 181 ); |
using( Graphicsg=Graphics.FromImage( b ) ) |
{ |
g.FillRectangle( m_flagColors[left], FLAG_X_OFFSET, 0, COLUMN_WIDTH, 161 ); |
g.FillRectangle( m_flagColors[centre], FLAG_X_OFFSET+COLUMN_WIDTH, 0, COLUMN_WIDTH, 161 ); |
g.FillRectangle( m_flagColors[right], FLAG_X_OFFSET+COLUMN_WIDTH*2, 0, COLUMN_WIDTH, 161 ); |
} |
returnb; |
} |
privatevoidGetColors() |
{ |
using( StreamReadersr=newStreamReader( @'C:SteamGamesSteamAppscommonEuropa Universalis IVcommoncustom_country_colors00_custom_country_colors.txt' ) ) |
{ |
stringline; |
while( ( line=sr.ReadLine() ) !=null ) |
{ |
if( !line.StartsWith( 'flag_color' ) ) |
continue; |
string[] parts=line.Split( '{', '}' )[1].Split( new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries ); |
m_flagColors.Add( newSolidBrush( Color.FromArgb( int.Parse( parts[0] ), int.Parse( parts[1] ), int.Parse( parts[2] ) ) ) ); |
} |
} |
} |
} |
} |
- Bitmap Font Generator (sometimes referred to as Bmfont) was added by indiefreaks in Jul 2013 and the latest update was made in Aug 2017. The list of alternatives was updated Dec 2020. It's possible to update the information on Bitmap Font Generator or report it as discontinued, duplicated or spam.
- Drawing text into a bitmap w/ stbtruetype. GitHub Gist: instantly share code, notes, and snippets.
What you are looking for is a lcd font generation tool. There are tools out there that will generate the header file and or code file including the proprietary atmel AVR progmem extensions. Google around for lcd font generator and you will find the types of tools I'm talking about. Some are free and some are not. Some allow specifying the. The disabled characters simply points to the same location in the bitmap as the previous character and gets its bitmap width and height set to 0. There still are entries for the disabled characters in the glyphs table, but no data in the bitmap for them — this keeps the.
Font To Bitmap
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment