CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

How do I maintain aspect ratio?

by kmccoy » 07 Oct 2014 17:14

I have many photos to display, all with different aspect ratios. How do I display them without stretching the pictures to fit the component? Stretching distorts the image.

I would like to display them in letterbox format if they are too wide or tall.

I have tried CSS and ImageCSS, but cannot get it to work correctly.
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by Jorge Sousa » 07 Oct 2014 18:48

Hello

Did you try with Proportional = True ?
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by kmccoy » 07 Oct 2014 18:52

cgdevtools_support wrote:Did you try with Proportional = True ?


Yes. The component size is fixed, but the image stretches to match the component.

I use a database connection to display PNG blob records in this component. This works great, but the aspect ratio / stretched pictures looks bad unless the original picture has the same ratio as the component.
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by Jorge Sousa » 07 Oct 2014 19:02

Hi

Please Kevin, could you send us one or more images that look bad and the size of the image control*.

I also presume that you are changing the images in an ajax/async event, isn't that right?
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by kmccoy » 07 Oct 2014 20:27

cgdevtools_support wrote:could you send us one or more images that look bad and the size of the edit.


Image

Image

The JQImage is 325x244 (W,H), but the size does not really matter. The image never sizes correctly, unless I am using wrong property values.

I also presume that you are changing the images in an ajax/async event, isn't that right?


Yes. The user enters search criteria and clicks a button. The app reads the editor fields and forms a MySQL query. The query is executed and passes the results to various DB components on my form. I then call RenderRegionAsync(rgnHits) to refresh all the DB components.

The CGJQImage is linked to one of the queries and displays the current blob. The user can use a DB navigator to flip through multiple pictures, if more than one exists for the search hit.

Code: Select all
PROCEDURE TfrmMuSearch.btnDoSearchClick(Sender : TObject; AParams : TStringList);
VAR
    FirstName,
    MiddleName,
    LastName,
    Sex,
    Hair,
    Eye,
    Feet,
    Inches,
    Weight,
    Age,
    AgeRange,
    ReportType,
    Agency :    Variant;
    Birthdate : TDateTime;
    Msg :       STRING;
    I,
    RecCount :  Integer;
BEGIN
    Msg        := '';
    FirstName  := GetEdtVal(edtFirstName, [EAlpha..EPunct]);
    MiddleName := GetEdtVal(edtMiddleName, [EAlpha..EPunct]);
    LastName   := GetEdtVal(edtLastName, [EAlpha..EPunct]);
    Sex        := GetComboVal(cbSex);
    Hair       := GetComboVal(cbHairColor);
    Eye        := GetComboVal(cbEyeColor);
    Feet       := GetComboVal(cbHeightFt);
    BuildRangeMsg(InRange(Feet, 0, 7), Msg, 'Height:Feet');
    Inches     := GetComboVal(cbHeightIn);
    BuildRangeMsg(InRange(Inches, 0, 11), Msg, 'Height:Inches');
    Weight     := GetEdtVal(edtWeight, [ENumeric]);
    BuildRangeMsg(InRange(Weight, 0, 999), Msg, 'Weight');
    BirthDate  := deBirthdate.Date;
    Age        := GetEdtVal(edtAge, [ENumeric]);
    BuildRangeMsg(InRange(Age, 0, 120), Msg, 'Age');
    AgeRange   := GetComboVal(cbAgeRange);
    BuildRangeMsg(InRange(AgeRange, 0, 5), Msg, 'Age:Range');
    ReportType := GetComboVal(cbReportType);
    Agency     := GetComboVal(cbResponsibleAgency);

    IF Msg <> '' THEN BEGIN
        mbCustomize(mtWarning, 'Sorry, there is a problem with the information you entered:<br><br>' + Msg);
        mbAddOK;
        mbShow;
    END;

    InhibitHits := FALSE;

    {Pass field values to UserSession query builder; Get record count}
    RecCount := UserSession.MPSearchHits(FirstName, MiddleName, LastName, sex, Hair, Eye, Feet, Inches, Weight, Age, AgeRange, ReportType, Agency, BirthDate, cbUnidentifiedRemains.Checked);

    RenderRegionAsync(rgnHits);

    {If record count=0 or record count>max hits then pop error dialog - exit}
    IF RecCount > MaxHits THEN BEGIN
        mbCustomize(mtWarning, 'Sorry, Your search returned too many reports.<br><br>Please add more search criteria to narrow your search.' + Msg);
        mbAddOK;
        mbShow;
        EXIT;
    END;

    IF RecCount = 0 THEN BEGIN
        mbCustomize(mtWarning, 'Sorry, Your search returned no reports.<br><br>Please change your search criteria to widen your search.' + Msg);
        mbAddOK;
        mbShow;
        EXIT;
    END;
END;


And the CGJQImage component:

Code: Select all
      object imgUserImage: TIWCGJQImage
        Left = 912
        Top = 87
        Width = 325
        Height = 244
        Hint = 'Click Add Photo button to upload a picture of this person'
        TabOrder = 32
        Version = '1.0'
        BorderOptions.NumericWidth = 3
        BorderOptions.Style = cbsInset
        DataLink.DataSource = IWUserSession.dsMupuImages
        DataLink.FieldName = 'filedata'
      end


Here is a screen shot of the web page. Note the stretched picture:

Image
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by Jorge Sousa » 08 Oct 2014 09:56

Hello

Thanks for the info, we're checking this now.

Why are you calling RenderRegionAsync(rgnHits) to refresh DB components? Don't they refresh automatically?
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by Alexander Bulei » 08 Oct 2014 12:23

Hi kmccoy,

Fixed/Implemted in v2.3.0.63.
Thank you.

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by Jorge Sousa » 08 Oct 2014 12:26

Hi again

After install the next version that will be released tomorrow morning,

You should set Proportional = True and optionally Center = True
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by kmccoy » 08 Oct 2014 15:54

cgdevtools_support wrote:Why are you calling RenderRegionAsync(rgnHits) to refresh DB components? Don't they refresh automatically?


No, they weren't. I don't know if it is because I use a parent frame to hold the "search" frame, or that I have multiple regions in the Search frame and the Submit button is on a different region than the DB editors.

Adding RenderRegionAsync fixed the refresh problem, but I am open to other solutions.
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by kmccoy » 08 Oct 2014 15:55

cgdevtools_support wrote:Hi again

After install the next version that will be released tomorrow morning,

You should set Proportional = True and optionally Center = True


Excellent! You guys rock!
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

Next

Return to JQImage

Who is online

Users browsing this forum: No registered users and 2 guests

Contact Us.