Unpacking Windows ICO and CUR icon containers locally
Windows .ico favicons and .cur mouse pointers are binary archives packing several distinct images inside one file. Decoding those containers directly inside image.worker.ts lets designers and developers inspect embedded sizes and export clean PNGs without uploading proprietary software assets.
Reading ICONDIR headers and 256-pixel zero-byte sizes
When you drop files or click Load sample ICO, the parser validates an ICONDIR header spanning 6 bytes (reserved = 0, type = 1 for .ico or 2 for .cur) and steps through 16 bytes per ICONDIRENTRY record. Because single-byte dimensions max out at 255, Windows stores 256 px sizes as zero.
Per the Microsoft Learn Win32 Icons format guide, each directory entry specifies the exact byte offset and payload length of its image frame. When you need to package fresh transparent graphics back into a web icon, build multi-size favicon.ico and Apple touch icons locally afterward.
Extracting hotspot X and Y offsets from .cur cursors
Cursor .cur files follow the exact same binary structure as .ico icons except header type equals 2 instead of 1. Directory bytes 4–7, which store color planes and bit count on .ico icons, instead store the cursor’s click hotspot X and Y coordinates in pixels.
Our extractor detects type === 2, labels the file header (CUR), and prints Hotspot (X, Y) beside the byte size under every extracted PNG frame. Preserving those coordinates helps front-end engineers convert legacy Windows pointers into CSS cursor: url(...) x y, auto declarations accurately.
Why do ICO files store multiple PNG and BMP layers?
One .ico bundle holds multiple pixel sizes and color encodings so operating systems and web browsers avoid scaling a single tiny bitmap across mismatched UI surfaces. High-DPI 256 × 256 desktop thumbnails typically embed compressed PNG data, whereas 16 × 16 or 32 × 32 legacy layers store pixel-aligned Device-Independent Bitmaps (DIBs).
Extracting Vista+ PNG payloads without recompression
Starting with Windows Vista, icon containers began embedding raw PNG streams directly to keep large 256 × 256 layers compact. Our reader checks the first four payload bytes for 0x89 0x50 0x4E 0x47 and extracts PNG-encoded frames directly without passing them through a <canvas> re-encoder.
Extracting raw bytes preserves original IHDR dimensions, exact zlib compression, and native alpha transparency bit-for-bit. When preparing crisp scalable brand marks at 1x to 8x pixel ratios prior to icon bundling, pair your workflow with vector SVG to Retina PNG rendering.
Rebuilding 1-bit to 32-bit DIB XOR and AND masks
Older icon layers start immediately with a BITMAPINFOHEADER spanning 40 bytes (BM file signature omitted), following the Microsoft Learn BITMAPINFOHEADER structure reference. Inside .ico containers, DIB biHeight doubles to cover stacked bitmaps: bottom-up XOR color pixels followed by a 1-bpp AND transparency mask.
This worker module can decode 1, 4, 8, 24, and 32 bits per pixel alongside BI_BITFIELDS (compression = 3) channel masks spanning 12 bytes and top-down scanlines. If every alpha byte in a 32-bpp frame equals zero, the decoder automatically applies that 1-bpp AND mask (maskBit === 1 sets alpha to 0).
Supported ICO bit depths, masks, and output encoding
Checking how each embedded payload decodes explains why one .ico container can hold mixed BMP and PNG badges inside the extraction grid. Every extracted layer presents consistent visual framing under the standard IANA image/vnd.microsoft.icon media type registry.
| Container frame type | Header / palette format | Transparency mechanism | Extracted PNG output | Typical icon size range |
|---|---|---|---|---|
1-bpp DIB (BMP) |
2-color BGRX palette |
1-bpp AND mask (1 = transparent) |
Lossless 32-bit RGBA PNG |
16 × 16 monochrome / legacy masks |
4-bpp / 8-bpp DIB (BMP) |
16- or 256-color BGRX palette |
1-bpp AND mask (1 = transparent) |
Lossless 32-bit RGBA PNG |
16 × 16 to 48 × 48 classic icons |
24-bpp DIB (BMP) |
Unindexed BGR byte triplets | 1-bpp AND mask (1 = transparent) |
Lossless 32-bit RGBA PNG |
32 × 32 / 48 × 48 XP-era icons |
32-bpp DIB (BMP) |
BGRA (BI_RGB or BI_BITFIELDS) |
Native 8-bit alpha or AND fallback |
Lossless 32-bit RGBA PNG |
16 × 16 to 128 × 128 smooth icons |
Embedded PNG |
Raw 89 50 4E 47 stream |
Native PNG alpha channel (colorType 6) |
Exact untouched PNG bytes | 64 × 64 to 256 × 256 Vista+ icons |
Testing with Load sample ICO loads sample-app-icon.ico, which deliberately mixes a 16 × 16 32-bit · BMP DIB layer alongside 32 × 32 and 64 × 64 PNG layers so you can verify both decoders side by side. Designers extracting individual frames from animated web sprites instead of static icon containers can use Extract GIF Frames.
Tip: Check the
bit · BMPvsbit · PNGpill on each card;24-bitand8-bitBMP layers often represent hand-drawn16 × 16pixel art that looks far sharper at small favicon sizes than auto-downscaled256 × 256PNGs.
Batch-exporting transparent PNGs and ZIP icon packs
Once every dropped .ico or .cur file unpacks inside image.worker.ts, each layer renders over a subtle checkerboard so translucent drop shadows and masked edges stand out clearly. Extracted layers encode cleanly under the W3C PNG Third Edition Specification for lossless editing everywhere.
Downloading individual layers and multi-file ZIPs
Clicking Save PNG on any card exports that exact layer as <stem>-<width>x<height>-<bitCount>bit.png. Clicking Download all as ZIP packages all layers from a single container, or organizes multiple dropped files into per-container folders inside extracted-icons-pngs.zip.
Because PNG streams are already Deflate-compressed, zipFiles stores each layer at compression level: 0 (Store mode) inside browser memory without wasting CPU cycles re-compressing compressed bytes. Dropping 10 multi-size Windows icons finishes almost instantaneously with zero upload wait times.
Repurposing favicons for pixel sprites and design specs
Product teams auditing legacy desktop installers, recovering missing brand logos from old favicon.ico files, or documenting mouse cursor themes get full-resolution transparent PNGs straight from binary containers. Zero files, file names, or icon layers leave your computer during parsing.
When extracted 16 × 16 or 32 × 32 toolbar icons inspire retro game assets or SVG badge remakes, quantize 16x16 icons into crisp pixel sprites offline using nearest-neighbor upscaling and retro console palettes. Allocated blob URLs revoke cleanly whenever you load new icons or close the tab.