Forum Discussion

csPlay's avatar
csPlay
Visitor
13 years ago

roScreen/roImageCanvas Image Fitting Problem

Hi,

I am currently using asyngettofile to download the image locally to the tmp:/ storage. However, the image returned differs in size. Essentially, I would like to do the "scale to fit" display mode functionality in roScreen or roImageCanvas for better customization instead of using the roSlideshowscreen. Has anyone encountered this problem before? Any share of approach or information is greatly appreciated.

Thanks in advance.

5 Replies

  • For roScreen, you'll need to calculate the scale based on the current screen resolution and use the DrawScaledObject method. For roImageCanvas, just specify the TargetRect with the width/height you want to scale to and you should be good to go. Regardless of which way you go, you'll need to calculate the scale yourself. There is no built-in "scale-to-fit" option for those screens.
  • Hi,

    Thanks for the prompt reply and your input. One problem of not being able to draw the scaled object is because of the unknown width and height of the image returned from the server. The image is a binary file which I used gettofile urltransfer method to store it directly to tmp:/ storage and then display it by point the url to the tmp:/ storage. In this case, since I do not know the width and height of that image, how can I determine the scale of the object?

    If I was to put the image in roSlideShow, it has no problem of putting the image to its scale option. I guess if my question can be more specific on how does the roSlideShowScreen determine the width and height of the image and scale it to the right size.

    Thanks.
  • With roScreen you would read the binary file into a roBitmap, then use DrawScaleObject with bm.GetWidth() and bm.GetHeight()
    With roImageCanvas you would use TargetRect. Which should work if already have the aspect ratio. You can get width and height and calculate aspect ratio of a local image file through roImageMetadata

    Let us know how that works.
  • Useful info! Many thanks.

    note: updated link - roImageMetadata

    "MSGreg" wrote:
    With roScreen you would read the binary file into a roBitmap, then use DrawScaleObject with bm.GetWidth() and bm.GetHeight()
    With roImageCanvas you would use TargetRect. Which should work if already have the aspect ratio. You can get width and height and calculate aspect ratio of a local image file through roImageMetadata]roImageMetadata

    Let us know how that works.