Announcement

Collapse
No announcement yet.

Image clipping on uLCD-32PT 4DGL

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

  • Image clipping on uLCD-32PT 4DGL

    I have a full screen image that I want to scroll off screen. It will not work going right, I can get it to work to about -180 left. However, I need it to go all the way (-320px or 320 px for x1) in at least one direction, but preferably in both.

    I have tried gfx_Set(Clipping,ON), gfx_Clipping(ON), gfx_SetClipRegion() and gfx_ClipWindow(0,0,320,240) in all combinations that I can think of. I have reviewed the samples, but all are for drawn objects, not images.

    Can this be done?

  • #2


    Any chance of a bit of example code of what you are trying?
    Regards,
    Dave

    Comment


    • #3
      The main function simply mounts the drive, sets orientation, and calls the following function. The idea is to be able to switch screens much like a smart phone. I have tried using the clipping functions, but if I declare it ON at the beginning of the following function the GIF doesn't even appear. right now this function will work until var horz reaches about -180px or where the image is -180px off screen. It will not work to right (not just because of the following coding, I gave up and just coded left movement).

      func lock()
      gfx_BGcolour(WHITE);
      gfx_Cls();

      setbaud(BAUD_2400);

      Ihndle := file_LoadImageControl("home_scr.dat", "home_scr.gci",1);
      img_SetPosition(Ihndle, lock_screen_gif, 0, 0); // set its position
      sys_SetTimerEvent(TIMER1,run_screen); // and we'll hook its event to timer 2
      sys_SetTimer(TIMER1,1);

      img_SetPosition(Ihndle, home_screen_bmp, 0, 0);

      com_Init(buffer,13,'\r\n');

      touch_Set(TOUCH_ENABLE); // enable the touch screen

      // now just stay in a loop
      repeat

      state := touch_Get(TOUCH_STATUS); // get touchscreen status
      x := touch_Get(TOUCH_GETX);

      if(state == TOUCH_PRESSED) // if there's a press
      xi := x;
      endif

      if(state == TOUCH_RELEASED) // if there's a release
      xf := x;
      horz := xf-xi; // calculate distance draged from touch point
      txt_MoveCursor(0,0);
      if (horz<=-160) // Slide image off screen if dragged more than 160px
      for(n:=horz;n>=-320;n:=n-10)
      img_SetPosition(Ihndle, lock_screen_gif, n, 0);
      img_Show(Ihndle, lock_screen_gif);
      next

      print("Power");
      else if (horz>=-10) // Hold for significant movement
      img_SetPosition(Ihndle, lock_screen_gif, 0, 0);
      sys_SetTimer(TIMER1,1);
      else // Slide image back to original position if not dragged far enough
      horz := 320+horz;
      for(n:=horz;n<=320;n:=n+10)
      img_SetPosition(Ihndle, lock_screen_gif, n, 0);
      img_Show(Ihndle, lock_screen_gif);
      next
      sys_SetTimer(TIMER1,1);
      endif

      endif

      if(state == TOUCH_MOVING) // if there's movement
      horz := x-xi; // calculate distance draged from touch point
      if (horz<=-10)
      sys_SetTimer(TIMER1,0); // pause animated gif
      img_SetPosition(Ihndle, lock_screen_gif, horz, 0); // set its position
      img_Show(Ihndle, lock_screen_gif);
      gfx_RectangleFilled(320+horz,0,320,240,BLACK); // draw box to hide image movement artifacts
      txt_MoveCursor(1,1);
      print(horz); // debug place value
      else
      endif
      endif
      forever

      Comment


      • #4


        The code above drags the image back and forth fine until I reach -180 px where the image locks position, but the black box still moves. If I release and the first if condition is true, the image does not move.

        The ELSE statement under TOUCH_RELEASE was not updated, here it is:
        [quote] else // Slide image back to original position if not dragged far enough
        for(n:=horz;n

        Comment


        • #5


          I have been trying this code just after the clear screen function, but the image never appears.
          gfx_ClipWindow(0,0,320,240);
          gfx_Set(CLIPPING,ON);
          Like I said though, the image will scroll off screen left to -180px then it freezes the image in place. I noticed this behavior on another program I wrote that had three evenly spaced 100px images scroll on screen. Instead of them all scrolling together, I had to start them each at just off screen and scroll them individually until they were evenly spaced. I don't have that luxury with this setup, I need to use a full screen animated gif since transparent images aren't supported (right?).

          Comment


          • #6


            I would appreciate any bit of feedback.

            I tried the same code with a 640x240 not knowing that GC would crop it to 320x240 despite not choosing to crop it. The difference was that the image showed up on startup with the above clipping code in place. Yet, it would still not move offscreen compeltely.

            Comment


            • #7


              Hi chopperwalker,
              We are currently reviewing PmmC for Picaso for the next release, and have noted what you have mentioned and will base some testing on your examples.
              We post the findings and fixes towards the end of the week.

              What version of Graphics Composer are you using, the latest one did resolve some cropping issues? (and is much friendlier to use)
              Regards,
              Dave

              Comment


              • #8


                GC 2.1.3.0 and PmmC uLCD-32PTGFX-R22.pmmc. The original full screen image was 320x240. The 640x320 image that I tried loaded into GC would set the location box width and height to 320x240, respectively. With cropping (box) selected or not (i didn't select it), it had width and height set to 640x320.

                GC has proved friendly to use; however, when I first started using it I struggled to load an animated GIF. The issue was that I had to choose a Movie and not an Image, otherwise the program would fail. Buttons and images in the program would load as a red "x" image and an "unhandled exception" error would occur. Just a heads-up.

                Thank you for the support.

                Comment


                • #9


                  ah, not sure if its fully your problem, but you have a fairly old graphics composer.
                  I suggest you download the latest one which is much better and fixed a lot of issues.
                  Regards,
                  Dave

                  Comment


                  • #10


                    What is the latest? because 2.1.3.0 is the one posted on 32PT product download page. I have tried the GC 3 (2.9.0.9) in the workshop menu, but I haven't managed to get things to display properly (red artifacts and placement issues with animated GIFs). I am sure that it could be due to my inexperience with the language.

                    Comment


                    • #11


                      4D Workshop3 IDE has the latest Graphics Composer.

                      Try following link. It has the same Graphics Composer that is included in 4D Workshop3 IDE plus the updated Graphics Composer User Guide.
                      Graphics Composer Software

                      I hope it will help.
                      -Bilal

                      Comment


                      • #12


                        Thank you, this version (2.9.0.13) has no issues displaying the animated GIFs and is much faster to load on a SD card than the older version that I was using. Obviously, the original issue for this post still stands, though.

                        Comment


                        • #13


                          hiI have a uLCD-32PT with touch ,I want to make a small cafe menu, with a PC serial port can send the selected menu. help me please!..

                          Comment


                          • #14


                            Obviously, the original issue for this post still stands, though.
                            Was that the clipping issue?

                            If so, are you sure, thought it was fixed?
                            Mark

                            Comment


                            • #15


                              hiI have a uLCD-32PT with touch ,I want to make a small cafe menu, with a PC serial port can send the selected menu. help me please!..
                              Crossed messages here oztastr, but please have a look at the code base, you should be able to make use of:-

                              http://www.4dsystems.com.au/code/index.php?node=77&id=96
                              (this opens a file, prints a selection in a button 'look alike' format)

                              and

                              http://www.4dsystems.com.au/code/index.php?node=75&id=75
                              (this shows you how to send bytes to/from a host)
                              Regards,
                              Dave

                              Comment

                              Working...
                              X