Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

pix3D (turning 2D image into 3D)

  • Filter
  • Time
  • Show
Clear All
new posts

    PBWin pix3D (turning 2D image into 3D)

    Turning 2D image into 3D

    Because the links posted to my contributions on the José Roca's forum have gone,
    here is a GDImage 7.00 updated version of the pix3D project.

    This project computes a grayed intensity for each pixel color, and it turns them into 3D visualization.
    This could be used to perform surface analysis, ground topography or any other mathematical computation, or just for fun.

    The default representation is using raster point (gl_dPoint) , but it could also use line (gl_dLine) or any other 3D primitive.

    To switch between point and line, you have to edit the code shown below:

    glRotatef(90, 1, 0, 0) '// ROTATION
    glTranslatef(0, 0, -rH) '// TRANSLATION
    if (nAnimate) then rPenSize = 2 else rPenSize = 1
    nPixStep = 2
    for y = 0 to nH - 1 step nPixStep
    for x = 0 to nW -1 step nPixStep
    zSplitColorARGB(PixColor(x, y), A, R, G, B)
    if (A) then
    rSize = rAlpha(x, y) * nMove

    'gl_dLine(rX1 - rW + x, rY1, rX1 - rW + x, rY1 - rSize, PixColor(x, y), rPenSize)
    gl_dPoint(rX1 - rW + x, rY1 - rSize, PixColor(x, y))

    end if
    glTranslatef(0, 0, nPixStep) '// TRANSLATION

    Note: You can use drag & drop from the Explorer to render a specific image.

    Turn the image to see the 3D side.

    Click image for larger version  Name:	capture.jpg Views:	1 Size:	162.3 KB ID:	814687

    Post questions or comments there:
    Attached Files
    Patrice Terrier
    Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).