Generate 3d mesh from 2d sprite?
You can use Hair particle system with Cube as Render &gt; Object.
Cubes are emitted based on texture Density.

Sprite to Cubes
Like here your image 16 x 16 px ...

add Plane, Subdivide by 4 to get 16x16 grid, delete one row to get 15x15 faces, because Cubes will be emitted from vertices
add Particle System &gt; Hair, Source &gt; Vertices with disabled Random, Render &gt; Object (assign Cube), Texture &gt; add New and under Texture Properties assign your image, enable ColorRamp (that switch image to Black&amp;White), under Influence enable Density.



Colors per cube should be easily taken from texture.
Like here, I just cant figure out what is wrong with setup in my file.
Edit: If this is still valid https://developer.blender.org/T42706 - emit from vertex is the issue.

Color per Cube
So you would have to go to Modifier Properties &gt; Convert. Join Ctrl+J Cubes (if you want cubes as one object). In Edit mode with all selected Unwrap &gt; From View. Switch to UV layout and in UV Editor switch to Individual Origins and Scale S the UV a bit.


Shader is smart enough ... UVMap is used automatically.

Notes:

You can use plane and use Subdivision Surface Modifier and Particle System after, just se Use modifier stack if enabled under Particle System
You can Separate P by Loose parts back into individual cubes if you need it.
You can use just a Plane (instead of Cube) for whole proces to make it lighter and use Solidify modifier as final touch :)
By default are images interpolated, to keep lowers images pixelated choose in Shader editor in Texture node &gt; Closest. For Particle System Texture go to Properties Editor &gt; Texture &gt; Sampling &gt; Interpolation disabled
in some of my screens is missing one Cube at a hat because I used Mapping &gt; Generated instead UV