XPM Viewer and Editor
A Visual Studio Code extension by John Nirmal for previewing and editing .xpm image files directly inside VS Code.
XPM files are commonly used in C and C++ projects as text-based image assets. This extension gives you a visual editor so you do not have to manually edit pixel data in raw text.
Features
- Preview
.xpm files as pixel art
- Edit pixels with a pencil tool
- Pick colors using the native color picker
- Use the eyedropper tool to select a color from the image
- Use the eraser tool to paint transparent pixels
- Resize the image canvas
- Zoom in, zoom out, and fit to view
- Toggle pixel grid
- Save changes to the current file
- Save As to a new
.xpm file
- Confirmation prompt before overwriting files
Usage
Open an .xpm file in VS Code.
Then choose one of these options:
- Click XPM Viewer: Open Editor from the editor title menu
- Right click the file and choose Reopen Editor With...
- Select XPM Editor
The file opens in a custom XPM editor with preview and editing tools.
Pencil
Paint pixels using the selected color.
Eyedropper
Click a pixel to set the current color from the image.
Eraser
Paint transparent pixels.
Color Picker
Choose the active paint color using the native color picker.
Resize
Change the canvas width and height. Existing image data is preserved where possible.
Save
Writes the edited image back to the current .xpm file.
Save As
Creates a new .xpm file from the edited image.
Save Behavior
When saving, the extension regenerates clean XPM text from the edited image data.
The saved image preserves:
- Width and height
- Pixel colors
- Transparent pixels
- XPM-compatible text structure
The saved file may not preserve:
- Original comments
- Original whitespace formatting
- Original symbolic color names
- Original palette ordering
Requirements
VS Code version 1.100.0 or newer.
Extension ID
ljn7.xpm-viewer
Repository
https://github.com/ljn7/xpm-viewer
Known Limitations
- The editor focuses on practical XPM image editing, not exact source formatting preservation.
- Some advanced XPM symbolic color metadata may be normalized when saving.
- Very large XPM files may be slower to edit depending on image size.
Release Notes
0.0.1
Initial Marketplace-ready release.
Added:
- XPM preview
- Pixel editor
- Pencil tool
- Eyedropper tool
- Eraser tool
- Color picker
- Resize controls
- Zoom controls
- Pixel grid
- Save
- Save As
- Overwrite confirmation
Author
Created by John Nirmal.
GitHub: ljn7
License
MIT