Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background image with new option of dpi scaling and BIRT-properties #1255 #1256

Merged
merged 7 commits into from Apr 15, 2023

Conversation

speckyspooky
Copy link
Contributor

The changes of these request includes the new posibilities that BIRT is able to use the image resolution of the original image dpi to create the correct scaling of the image. In addition to it the base properties background image height and width can be used. The both properties are also able to be used on script level.

The change includes the changed components:

  • designer
  • preview
  • emitter.HTML
  • emitter.PDF
  • emitter.PPTX

Till now the emitter wasn't able to scale the images. This option is added. To bet a better handling of all, the base class "background image info" is enhanced to implements the main functions and new properties.

Overview of changed classes:
Overview-Changed-Classes-1255.xlsx

Examples of testing:
Test-Examples-1255.zip

Expamples of results:
Result-Examples-1255.zip

@speckyspooky speckyspooky self-assigned this Apr 10, 2023
@speckyspooky speckyspooky added the Enhancement Small change to improve the current supported functionality label Apr 10, 2023
@speckyspooky speckyspooky added this to the 4.14 milestone Apr 10, 2023
@hvbtup
Copy link
Contributor

hvbtup commented Apr 11, 2023

I didn't look at the code, just at the output.

First of all, great work! This is absolutely OK for my use case.

Do I understand correctly that "auto" (or not specified) the width and height is computed from the image's pixel and its DPI information?

Did you also test with a different image without DPI information (such that the image has intrinsic proportions, but not intrinsci dimensions?

If one dimension is specified and the other is auto, the behavior is not as expected according to https://developer.mozilla.org/en-US/docs/Web/CSS/background-size. Anyway, I don't mind.

@hvbtup
Copy link
Contributor

hvbtup commented Apr 11, 2023

I downloaded the All-In-One-Designer artifact from this PR and tested myself.
I saved the same image without DPI (I used BMP format for this).
In this case, BIRT still seems to assume that 96 DPI are specified in the image.
I also tried setting the imageDpi property of the report. This had no effect.
OK, so it's the same behavior as before.

Though personally I don't mind the distorted image if only one dimension is specified, I think others might.
According to the Mozilla page mentioned above, the image should not be distorted:

auto
Scales the background image in the corresponding direction such that its intrinsic proportions are maintained.

@speckyspooky
Copy link
Contributor Author

My target was to get a first step of improvement to get the base handling and I would say it is given.
If I have time I will take a look after your specific constellation:

  • width: 100px, height: auto
  • width: auto, height: 100px

The property of the DPI-usage directly on report level make no sense because you would say in this case all images must be use the same DPI-value. But in the most cases the it is specific of each image.
The idea later is to add a new property background-image-dpi to handle it directly. But before we can do it we habe to merge the changes of diagonales and this one because we have dependencies on implementation side.
(Yes, the default is same like before on 96dpi.)

@hvbtup
Copy link
Contributor

hvbtup commented Apr 11, 2023

Definitely this PR is an improvement to the current situation.
I'm +1 for merging it.

@wimjongman wimjongman self-requested a review April 11, 2023 13:31
Copy link
Contributor

@wimjongman wimjongman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Please go ahead and squash and merge.

@speckyspooky
Copy link
Contributor Author

I will double check the pull request due to the merge of the diagonal-antidiagonal changes.

Independend of the merge I have done additional testings and added 2 changes (locally):

  1. I figured out 2 wrong image calculations - I fixed it
  2. I implemented a first version of the scaling if only 1 value, width or height is set and the another value is "auto"

I check in the next days my standard test cases and if I can finish the test sucessfully I wil do an additional commit.

@speckyspooky
Copy link
Contributor Author

@wimjongman Could you please re-check the additional changes before I start the merge. Thanks in advance.

@wimjongman
Copy link
Contributor

This is a bit too big to be reviewed. When looking at the code, I wonder how the images are disposed of. You know that creating images is notorious for memory leaks. Also, I see a lot of code that looks duplicated. There are a lot of new setImage methods. But the code is too big and spread out over too many files for me to be able to do a proper review.

@speckyspooky
Copy link
Contributor Author

Yes, you are right that there are some codes "seems" to be duplicated. The reason is that the containing elements are completely different objects which are inherit from different parents.
We have for the output emitter the BackgroundImageInfo-class which is the representation of the master lcass.
But for the Grid-, Table-, Row-, Cell-elements of the designer are own classes used from the original concept.
The core functionality of the background-handleing are the same in the most parts but not at all and I cannot centralize the functionality to one class of all.
Especially the HTML-Emitter is the special at all because he use special handling in additonal to all together with the AttributeBuilder.

If you want, I cann add all of my test-reports to the pull request - here my test results like PDF-output.
background_image_testcase-phase02_#1255.zip

Please let me know what I can do to offer you the according/relevant information.

@speckyspooky
Copy link
Contributor Author

An additonal information, the central handling of background images according with the disposing of images aren't changed from my side. The enhancement is located on the calculation of the image dimenson and there usage.
Yes I know that the images are very sensible of memory leaks. With these changes we haven't more leak, we would have the leaks like before.
I cannot exact say where it is located but during my debugging I saw some point there the dispose will be fetched on cenral points.

@hvbtup
Copy link
Contributor

hvbtup commented Apr 14, 2023

Wow, coding after midnight!

@hvbtup
Copy link
Contributor

hvbtup commented Apr 14, 2023

I agree with Wim that a lot of code seems duplicated.

But that is caused by BIRT's internal concepts and code structure, as Thomas explained. I noticed this in my initial attempt (withdrawn PR).
I don't think this code smell can be fixed with reasonable effort.
And the code smell is old, it was not introduced with this PR.

Regarding image disposal, I don't know when it happens but I'm pretty sure that the images are garbage-collected when the design is and the Run/Render/RunAndRenderTasks are gc-ed.

@wimjongman
Copy link
Contributor

Ok, so please merge. No guts, no glory.

@speckyspooky speckyspooky merged commit 63f06dd into eclipse-birt:master Apr 15, 2023
2 checks passed
@speckyspooky
Copy link
Contributor Author

Merge is done.

@speckyspooky speckyspooky deleted the background_image_1255 branch September 16, 2023 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Small change to improve the current supported functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants