1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

How To: Modify PCX Files with MSPaint

Discussion in 'Civ3 - Tutorials, Reference, & Guides' started by Quintillus, Apr 1, 2011.

  1. Quintillus

    Quintillus Archiving Civ3 Content Supporter

    Joined:
    Mar 17, 2007
    Messages:
    6,354
    Location:
    Columbus
    Years ago, I, probably like many other newcomers, was mystified by why I couldn't modify PCX files in Microsoft Paint and have them work correctly in Civ3. Well, good news, after years of searching, I have at last discovered a way of modifying PCX files in Paint and having Civ3 accept them!

    Those familiar with Paint are probably wondering how to even save PCX files in Paint. That indeed has been removed from recent versions of Paint, but fortunately, the Windows 3.11 version supports it! So for this tutorial, you'll have to use the Windows 3.11 version of Paint. It works just fine on XP (32-bit only), and probably will work on Vista and 7 (32-bit only) as well.

    How to get Paintbrush for Windows 3.11 onto Windows XP (skip if you already have it)

    Spoiler Paintbrush on XP :
    We'll assume you have a working Windows 3.11 install. If not, dust out the old floppies or consult eBay. You'll find PBRUSH.EXE in the C:\Windows folder. You'll need to transfer this over to XP. Choose your preferred method (floppy disc, e-mail, etc.), and get it over to XP. Then put it somewhere where you'll be able to find it later. Also copy PBRUSH.HLP if you think the Help might come in handy. If you are running Windows Vista or 7 (32-bit only), see this article for help on how to view .hlp Help files.


    The trick to getting Paint to save PCX files in a format Civ3 will understand is the color depth of your monitor. If you just save the PCX files with your standard, 32-bit color monitor, you'll be in the same predicament I was in years ago, wondering why Civ3 crashed to the desktop with modified PCX files. Paint uses the color depth of your monitor to determine what color depth to use when saving PCX files, and Civ3 only supports 256-color PCX files, so you must have your monitor set to 256 colors to use Paintbrush to edit Civ3 PCX files.

    So the first process is to change your monitor to 256 colors. Unfortunately this isn't that straightforward on most modern computers. So we'll use a picture tutorial. I'll be using Windows XP in the tutorial, but the process should be nearly identical in 98/ME/2000, and hopefully similar enough to follow along in Vista/7.

    First, go to Display Properties (right-click on your desktop and select Display Properties). Go to the Settings tab, and click the Advanced button.



    In the advanced settings window, choose the Adapter tab, and choose the List All Modes option.



    You'll get a list of all the display modes your monitor supports. The key is to select one with exactly 256 colors. Ideally this will be the native resolution of your monitor as well; I've selected 1280x800x256 as that's the best 256-color display for my monitor. The Hertz doesn't matter for the sake of PCX editing.



    Now OK out of the dialogs, saying "Yes" when asked if you want to keep the new settings. You're ready to go into Paintbrush!

    Go to wherever you saved PBRUSH.EXE from Windows 3.11, and double-click it to start. Go to File -> Open, and navigate to where the PCX file you want to modify is. Don't forget to use the drop down "List Files of Type" to select PCX Files (*.PCX) instead of the default "Bitmap files (*.BMP, *.DIB)".



    Okay, the file is open! Make your changes! The View -> Zoom In option is handy here for precision modifications, although you have to remember to Zoom Out again before you can, for instance, save.



    A nice simple modification. But will it work in-game? Without the color depth modification, Civ3 would crash to the desktop, and the GIMP would be bamboozled by the files and 'give up':



    But not this time! It loads in-game!



    You'll notice that although the 'HI' addition most certainly shows up, the colors are off. The issue here is that Paintbrush is overwriting some of the palette colors with its brush colors. There is promise for overcoming this, as Paintbrush thoughtfully includes a "Get Colors..." option that can import a palette. Unfortunately, I've thus far been unable to find a program that can export a palette from a PCX file into the .pal format that Paintbrush understands, other than Paintbrush itself.

    Still, if all you need is the correct shapes and forms, and you don't mind the colors being slightly off, you can now use MSPaint to do all your PCX editing!!!
     
  2. AnorakTel

    AnorakTel Chieftain

    Joined:
    Aug 21, 2012
    Messages:
    36
    Location:
    Waikkikamukau
    I use a free program IrfanView that I found on the web.

    It's useful for converting between graphics formats. So I capture a suitable photo on the web. Edit it with paint to produce a bitmap and then use IrfanView to make a pcx.

    The problem is that you have to make a 256 colour bmp file to get a usable pcx. Paint is useless for this as it would use its standard palette and there is no way that you get a decent rendition.

    So I knocked up a program - Bump Converter - that messes around with BMP file header. One of the things it does is look at a bmp file and choose what it thinks are the best 255 colours to make the palette. (Note the 256th colour is Magenta - it is for CIV.)

    It is a bit clunky and there isn't any help because it was meant for my own amusement.

    Read in a BMP file
    Extract the colours by hitting "Set to 8 bit" (Can take a long time)
    Then apply the palette by hitting "<<Apply" or "<<Apply*". Two different algorithms - I think Apply* is better - and save to a new bmp file.
     

    Attached Files:

  3. MPK

    MPK prince

    Joined:
    Nov 23, 2011
    Messages:
    333
    Gender:
    Male
    Location:
    Auckland, New Zealand
    unfortunately I'm using windows7 64bit, not 32bit.....

    @AnorakTel:
    I keep reading about this IrfanView. I will have a look.
    I can, or it seems I can make .pcx files on Gimp 2.8. The files say .pcx anyway. First I make a Gimp xcf file, then export as a .pcx by "extension".
     
  4. Quintillus

    Quintillus Archiving Civ3 Content Supporter

    Joined:
    Mar 17, 2007
    Messages:
    6,354
    Location:
    Columbus
    Haha, I like that after 16 months this thread got a few replies. I see the thread is serving its purpose (note when it was first posted).

    First, welcome to CFC! :band:

    I took your program for a test run. It seems to basically work, although you're right, the set to 8-bit can take a long time - it seems to get slower as it progresses. I also ran into an error once with the attached .bmp file:



    Code:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
       at System.Drawing.SafeNativeMethods.Gdip.GdipFillRectangleI(HandleRef graphics, HandleRef brush, Int32 x, Int32 y, Int32 width, Int32 height)
       at System.Drawing.Graphics.FillRectangle(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height)
       at Bump_Converter.Form1.ExtractPalette(CColourTable colTab)
       at Bump_Converter.Form1.ReduceTo256ColoursCont()
       at Bump_Converter.Form1.timeMain_Tick(Object sender, EventArgs e)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3634 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    Bump Converter
        Assembly Version: 1.0.0.24499
        Win32 Version: 1.0.0.24499
        CodeBase: file:///D:/My%20Documents/Downloads/Bump%20Converter/Bump%20Converter.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3634 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3634 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3636 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.
    
    But it worked fairly well on my smaller kitty cat image (converted).



    I think the primary area for improvement at this point would be speed, as even for the rather small kitty image it took several minutes. I decided to go for the gold at first, with a 4096x4096 image of Earth. Considering that Windows Explorer won't open it, it was probably overly ambitious.

    Sad day! No old computers with 32-bit Windows? I've since switched to XP 64-bit on my new computer, but still have 32-bit on my laptop... although if I'm going to do anything serious with PCX's, I'll use GIMP. GIMP seems to be the generally preferred PCX option here. I use GIMP 2.4, because I know where the colormap and such are from Kyriakos's tutorial. Even though the menus are in Greek, it's easier for me to find my way around than the newer GIMP in English.

    I've also heard of Irfanview but haven't played around with it too much. From when I have used of it, it seems nice and fast (versus GIMP's slow startup).
     
  5. MPK

    MPK prince

    Joined:
    Nov 23, 2011
    Messages:
    333
    Gender:
    Male
    Location:
    Auckland, New Zealand
    I'm glad this got bumped after 16 months. I was told I needed this gadget and that gadget to make .pcx files. All I need is Gimp. {I couldn't make head or tails of FlicSTER)

    I also found the tutorial on Gimp by Kyriako easy to follow. What is the saying, "a picture paints a 1000 words". I only got stuck with the saving of the images. It is completely different on 2.8 compared to the 2.6 tutorial. I did download 2.,6 and put it in a folder just in case I never got to understand 2.8.
    I got it figured out with some very simple but excellent advice [direction]. What was needed to be done on 2.8 was ["Save as" .xcf > "Export to" (large).pcx by extension > "Export" (small).pcx by extension.]
    I'm assuming making the _32.pcx is just the same [?]. (I'm still learning, slowly)

    @AnorakTel - welcome, great to see another kiwi on board.
     
  6. Quintillus

    Quintillus Archiving Civ3 Content Supporter

    Joined:
    Mar 17, 2007
    Messages:
    6,354
    Location:
    Columbus
    Yeah, the GIMP is all you need. It does have fairly complex menus, but once you know where things are, it does the trick nicely. It's way better than Windows 3.11 Paintbrush, even if you can technically do some things with it.

    The units_32.pcx should follow the same process, the only tricky thing there is that you still only have 256 colors, and your source units might use different 256 color palettes, for a lot more than 256 being cut down to 256 for the units_32.pcx. However, I'm not actually a graphics modder, so I'm probably not the best one to ask. I'm more of a "see what's possible" type person, which is what led me to try using such an old version of MSPaint.
     
  7. AnorakTel

    AnorakTel Chieftain

    Joined:
    Aug 21, 2012
    Messages:
    36
    Location:
    Waikkikamukau
    Quintillus
    Thanks for the feedback.
    I converted The polarbear image (attached) and it worked but I'll check through the program. It looks like the crash happened as it was drawing the new palette.

    It takes a long time because it selects colours from the picture that are furthest away from any colour that is already in the palette. So it starts with Magenta (Civ requirement) and looks at every pixel to find the colour furthest from magenta. Then it finds the pixel furthest from both these colours and so on. No optimisation so it involves a massive calculation. For the Polar bear picture it needs about 10,000,000,000 multiplies and 15,000,000,000 adds. (140,000,000 multiplies for the final pixel) 4kx4k for the World - erm we are talking serious high numbers maybe 7,000,000,000,000 multiplies.

    It wasn't a problem for the small Civ pictures. Finish the edit and go for a coffee whilst the machine chunters away.

    This is my Regional Assembly small wonder - original piccie (Walthamstow Town Hall) and after clipping and conversion.

    If I do any more picture conversion, I'll have to rewrite to improve the algorithm and perhaps try to feather the colours in the sky. (Or maybe just use Gimp)
     

    Attached Files:

Share This Page