How to change image height and width dimensions using an expression or code

  • Is there a way to specify the image height and width dimension for an image pulled from a database?

    I am storing the desired image dimensions in the database along with the images. Each image to display can have a different height and width, and the display dimensions are not the same as the actual dimensions of the image (so AutoSize won't work). I am using FitProportional.

    The height and width fields do not allow expressions. The embedded Code window allows for OnInit code, which is run before the fields are available to the code, so I cannot seem to write Image1.Height = "2cm." I don't believe there is anything other than OnInit available in the Code window, like an OnPreRender.

    Does anyone have any ideas? SQL Server 2008. VS 2008. Thank you.

  • Try changing the Sizing property to AutoFit or FitProportional, etc. (whichever works best for you)

    May not solve your problem if your image is outsized, but if you save images at the sizes you want in the report, that should work.

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

  • All the images are stored at a larger size than their intended dimensions and are and shrunk down when rendered on the report as a way of increasing their resolution. That is why I need them to be resized. I need the dimensions to be what they actually are in the database divided by 3.

  • And you specifically need the images to be one-third of whatever they're saved as? Seems like there would be two options here:

    1 - save them at the correct size in the first place, then you don't have to manipulate it when retrieving from the db

    2 - use FitProportional to maintain the correct aspect ratio, and have a fixed size for the display image, which will maintain the layout of your report.

    Other than that, still digging for other options.

    Will either of the above do the trick?

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

  • If I save an image at 2x2, it will print at 96dpi, which looks noticeably blurry when printed and on screen. If I save the image as 6x6, then shrink it down to 2x2 using FitProportional, the image prints at 288 dpi (96 x 3) and the print quality is noticeably better. A graphic designer told me many years ago to always use integer multiples when using this trick, which is why it is x 3 instead of targeting 300 dpi.

    One of the best strategies is the one you mentioned where I use a fixed size of something like 2x2 and pad each image with the necessary whitespace to fill up those fixed dimensions. That is the direction I am leaning in since I can't find any other option that works well.

    I was thinking a Custom Report Item would be the best option, but Teo Lachev wrote that custom report items are not allowed in page headers, which is one place these logo images might need to be put on some reports.

    I think there might be a way to change the default resolution of reports from 96dpi to 300dpi. If I could get a report to print nicely without doing the resize trick, then it would make things easier. I might be able to use AutoSize in that case.

    Another option is using a Report Definition Customization Extension, but the only example I have seen of one of those in the last chapter of Teo's book and they look tricky to use.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply