Img4Dat
Img4Dat converts a bitmap into an LDraw pattern: the image is reduced to a few colors, the color borders are traced as paths, and the areas are triangulated and saved as an LDraw .dat file. In between you can edit the graph and choose the template, i.e. the part the pattern is placed on.
Download
| Version | System | File |
|---|---|---|
| 2.0.0 | Windows 10/11, 64 bit | Img4Dat-2.0.0.zip (approx. 300 KB) |
Img4Dat requires the Microsoft .NET 10 Desktop Runtime (x64) from dotnet.microsoft.com. Choose “.NET Desktop Runtime” for Windows x64. If it is missing, Windows shows a message with a download link when Img4Dat is started.
Installation
Unzip the archive into a folder of your choice and start Img4Dat.exe. Nothing is installed. Settings
and log files are written next to the program (Settings.xml, Logs\), so use a folder where
you have write access.
Quick start
- Open Image … – Load the picture (BMP, PNG, JPG, GIF, TIFF).
- Colors – Right-click into the source image (left) to add a color to the palette. The quantized image
(right) shows the result. Enter the LDraw color number in each palette button. Pencil, Fill and
Re-quantize fix single pixels or areas. Undo with
Ctrl+U(image). - Find Paths – Traces the borders between the colors.
- Edit the graph – Select points (click,
Ctrl+click, drag a rectangle) and use the tools above the graph: add, delete, merge points, points on a line or circle, circular arc, Bezier curve, peak. Undo withCtrl+Z(graph). - Template – Choose the part the pattern is placed on (second toolbar row), then Fit or adjust X, Y and Scale.
- Triangulate & Save (
Ctrl+S) – Creates the triangles and saves the LDraw pattern file.
Graphs can be saved and loaded (Save Graph / Load Graph) to continue later.
Output
The pattern file contains the header lines
0 !LDRAW_ORG Unofficial_Pattern
0 !LICENSE Licensed under CC BY 4.0 : see CAreadme.txt
Please complete title, author, category and keywords before submitting a pattern to the LDraw Parts Tracker.
Templates
Img4Dat comes with 17 templates:
| Part | Description | View |
|---|---|---|
| 3070b | Tile 1 x 1 with Groove | from above |
| 98138 | Tile 1 x 1 Round with Groove | from above |
| 3069b | Tile 1 x 2 with Groove | from above |
| 2431 | Tile 1 x 4 with Groove | from above |
| 4162 | Tile 1 x 8 | from above |
| 3068b | Tile 2 x 2 with Groove | from above |
| 14769 | Tile 2 x 2 Round with Round Underside Stud | from above |
| 87079 | Tile 2 x 4 | from above |
| 22385 | Tile 3 x 2 with Angled End | from above |
| 3005 | Brick 1 x 1 | from the front |
| 3004 | Brick 1 x 2 | from the front |
| 3010 | Brick 1 x 4 | from the front |
| 4066b | Duplo Brick 1 x 2 x 2 Type 2 | from the front |
| 3039 | Slope Brick 45 2 x 2 | perpendicular to the slope |
| 973 | Minifig Torso | from the front |
| 3626b | Minifig Head with Blocked Hollow Stud | from the front |
| 3626c | Minifig Head with Hollow Stud | from the front |
Your own templates
Templates are LDraw files in the Templates folder next to the program. Triangles (type 3 lines)
describe the surface the pattern lies on; additional type 2 lines mark hard edges. Optional line:
0 !IMG4DAT PLANE x y z
It sets the view direction onto the pattern surface, pointing from the viewer to the part (LDraw: −Y is up), e.g.:
| Line | View |
|---|---|
0 !IMG4DAT PLANE 0 0 1 | front (default) |
0 !IMG4DAT PLANE 0 1 0 | top (tiles) |
0 !IMG4DAT PLANE 0 0 -1 | back |
0 !IMG4DAT PLANE 1 0 0 | left side |
0 !IMG4DAT PLANE -1 0 0 | right side |
0 !IMG4DAT PLANE 0 1 1 | a 45° slope seen perpendicularly |
All included templates contain such a line. A template first appears centered and fitted to the image. Edges where two template triangles meet at an angle cut the pattern, so no pattern triangle spans a fold.
License
Img4Dat is freeware, not open source. You may use it free of charge, for private and commercial purposes,
and pass it on complete and unmodified. The exact terms are in LICENSE.txt in the archive. Img4Dat is
provided “as is”, without warranty of any kind. Patterns, graphs and other files you create with Img4Dat belong
to you.
- The algorithms in Img4Dat were strongly inspired by the documentation of two excellent projects: Potrace by Peter Selinger (path tracing and polygon simplification) and Triangle by Jonathan Richard Shewchuk (constrained triangulation). Img4Dat is an independent implementation and contains no code from these projects. Many thanks to their authors.
- Img4Dat uses Apache log4net, which is licensed under the Apache License, Version 2.0.
- The templates are derived from parts of the LDraw Parts Library, which is licensed under CC BY 4.0.
LEGO® is a trademark of the LEGO Group, which does not sponsor, authorize or endorse this software. LDraw™ is a trademark of the Estate of James Jessiman.