Announcement

Collapse
No announcement yet.

BMP images straight from uSD card PICASO

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BMP images straight from uSD card PICASO

    Hey, I remember reading a post a while back where the person included a code snippet for using byte by byte file read to draw a BMP on screen. 




    Problem is I cannot find it using a search or manually clicking through the forum pages..  anyone know where this is or does anyone have the code they can share?




    THanks

    Andy
    MicroLec Industries P/L
    www.intelligym.com.au

  • #2


    Hey, I've got some rough code that displays a raw bitmap file straight from the SD card. It's a long time since I did any work on this, but it should be OK.
    You'll need to set "_dirfname" to the file you wish to open.
    Good luck!

    var _dirfname[7]; // File name

    func disp()

    var hnd, x, y, c, p, col;
    var red,green,blue, xpos,ypos;
    var dummy;

    xpos := 0; ypos := 0;

    hnd := file_Open (_dirfname, 'r');
    if (hnd == 0)
    print ("Couldn't open file");
    else
    file_Seek(hnd, 0x0000, 0x0012); // width
    x := file_GetC(hnd);
    txt_MoveCursor(16,0);
    print(" Width=",x,",");
    file_Seek(hnd, 0x0000, 0x0016); // height
    y := file_GetC(hnd);
    ypos := y;
    file_Seek(hnd, 0x0000, 0x001C); // 8 / 24 / 32 bit colours
    c := file_GetW(hnd);
    file_Seek(hnd, 0x0000, 0x002E); // colours in the colour pallette (for 8 bit colour)
    p := file_GetW(hnd);
    print("Height=",y,",",",depth=",c, ",palette=",p);
    file_Seek(hnd, 0x0000, 0x0036);

    if (c == 8)
    // Read colour palette from
    endif

    repeat
    xpos := 0;
    while (xpos < x)
    if (c != 8)
    blue := file_GetC(hnd);
    green := file_GetC(hnd);
    red := file_GetC(hnd);
    if (c == 32)
    dummy := file_GetC(hnd); // skip over alpha - not used
    endif
    col := gfx_RGBto565(red,green,blue);
    else
    col := c;
    endif
    gfx_PutPixel(xpos,ypos,col);
    xpos++;
    wend
    ypos--;
    if (ypos < 0)
    break;
    endif
    until (file_Error() != 0)
    endif
    endfunc

    Comment


    • #3


      that looks like it thanks..

      I thought about this some more and is just as much work for me resizing and saving the images to BMP, as it is using Graphics Composer.  so decided just to go with GC..  

      I will be sure to keep this code snippet in my list of programs just in case ..

      Thanks again,

      Andy
      MicroLec Industries P/L
      www.intelligym.com.au

      Comment

      Working...
      X