Announcement

Collapse
No announcement yet.

file_Image() problem

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

  • file_Image() problem

    Hi, i am showing a image i took from the display whit file_ScreenCapture() and the i show it whit this code:
    if(!file_Mount()) txt_MoveCursor(3,5); putstr("\nError\n"); while(!file_Mount()); endif
    var handle; handle := file_Open("draws.img", 'r'); file_Image(0,31,handle); file_Close(handle); pause(3000);
    file_Image(0,31,handle); is suppose to show the image at x=0 and y=31 it is showing perfectly the image but i have to show the image x=0 and y=40, when i put 32 and above instead of 31 for y axis the image is not showed any more. It is only showed for values of y axis under 31 why? There is a limit?
    Thanks

  • #2


    You haven't said how big the captured image is.

    If it's Y position plus its height exceeds the screen size it wont display, to get around that you need to turn clipping on.

    try inserting

    gfx_Clipping(ON) ;

    before the file_Image
    Mark

    Comment


    • #3


      Hoooo thanks that was the problem, i correct the height of the image and put clipping window. Last question, if i have many screen captures in the file every time i use file_Image a new image is displayed, if i do:
      handle := file_Open("draws.img", 'r');handle := handle + 1;file_Image(handle);
      Will it open the second image in the file? And how i can delete for example image number 2 of the file without affecting the others?
      Thanks

      Comment


      • #4


        Altering the handle will get you nowhere.

        As per the manual "If there is more than 1 image in the file, it can be accessed with file_Seek(...)."
        Mark

        Comment


        • #5


          Yeah i read that but i dont know how to use it and i didnt find any example program. I know the handle is the pointer i get whit file_Open() but how i can know what memory pointer i have to read to go through the images i saved?
          Thanks

          Comment


          • #6
            To access the images in the file that has been created, it is necessary to calculate the offset to the required image. Here is an example that may help.

            #platform "uLCD-32PT_GFX2"
            #inherit "4DGL_16bitColours.fnc"

            // demo tiling of an image, and randomizing the tiles
            // The formula for calculating the image position is W*H*2+6

            // each tile will be 40x40, set some constants
            #constant W 40
            #constant H 40
            #constant IMAGE_SIZE W*H*2+6 // 2 bytes per pixel, 6 bytes for header
            #constant TILES_WIDE 240/W // number of tiles accross
            #constant TILES_HIGH 320/H // number of tiles high
            #constant TILE_COUNT (240*320)/(W*H) // calc number of tiles

            #NOTICE "Tile Count ", TILE_COUNT

            func main()
            var hFile, i,x,y;
            ////var addrLO[TILE_COUNT];
            ////var addrHI[TILE_COUNT];

            /* mount uSD FAT16 */
            putstr("Mounting...\n");
            if(!file_Mount())
            while(!file_Mount())
            putstr("Drive not mounted...");
            pause(200);
            gfx_Cls();
            pause(200);
            wend
            endif
            putstr("Drive mounted.\n");
            pause(1000);

            // put a full screen image on the display
            hFile := file_Open("T240X320.GCI",'r') ; /* image is 240x320 */
            file_Image(0,0,hFile) ;
            file_Close(hFile) ;


            // erase old storage file if it exists
            if (file_Exists("mytiles.img"))
            file_Erase("mytiles.img");
            endif

            // capture the tiles to the file
            hFile := file_Open("mytiles.img", 'w');
            txt_Opacity(TRANSPARENT);
            txt_FGcolour(YELLOW);
            i:=0;
            for(y:=0;y<TILES_HIGH;y++)
            for(x:=0;x<TILES_WIDE;x++)
            gfx_MoveTo(W/3+x*W,H/3+y*H); // position the text
            print(i++); // print the tile number
            file_ScreenCapture(x*W, y*H, W, H, hFile);
            next
            next
            file_Close(hFile);
            gfx_Cls();


            // display the tiles randomly
            // use file_Index to seek the required address and display shuffled tiles
            hFile := file_Open("mytiles.img", 'r'); // open the tile file for reading
            for(y:=0;y<TILES_HIGH;y++)
            for(x:=0;x<TILES_WIDE;x++)
            file_Index(hFile, IMAGE_SIZE>>16, IMAGE_SIZE&amp;0xFFFF, ABS(RAND()%TILE_COUNT)); // select a random tile
            file_Image(x*W, y*H, hFile); // place it
            next
            next
            file_Close(hFile);


            repeat forever

            endfunc
            Regards,
            Dave

            Comment

            Working...
            X