Bug 234432 - [Improve Report Layout Capabilities] Image appears enlarged in pdf report
Summary: [Improve Report Layout Capabilities] Image appears enlarged in pdf report
Status: VERIFIED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.2.1   Edit
Hardware: PC Windows XP
: P2 normal with 1 vote (vote)
Target Milestone: 2.5.0 M5   Edit
Assignee: Yu Chen CLA
QA Contact: Tianli Zhang CLA
URL:
Whiteboard: Autoed
Keywords: Documentation, plan
: 237426 261220 (view as bug list)
Depends on: 260350
Blocks:
  Show dependency tree
 
Reported: 2008-05-28 13:20 EDT by hgk CLA
Modified: 2009-07-23 05:52 EDT (History)
12 users (show)

See Also:


Attachments
png file (8.57 KB, image/x-png)
2008-06-20 13:13 EDT, hgk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description hgk CLA 2008-05-28 13:20:31 EDT
Build ID:  M20071023-1652

Steps To Reproduce:
1. Find a png image of known size and place it in c:\
2. Create a new rptdesign and add image report item to it. 
3. Set the size of the image report item to the size of the png image and the url to the c:\myimage.png
4. Create a pdf report. print it.
5. Open the png image in a editor(ex Paint on windows) and print it.
The image in pdf report is 30% larger than the actual png image.


More information:
http://www.birt-exchange.com/modules/vbulletin/showthread.php?t=10762
Comment 1 Wei Yan CLA 2008-06-09 23:19:04 EDT
can the designer get the DPI of the design environment and set it in the design file? so the engine can use the DPI to generate the PDF/PS.
Comment 2 Wei Yan CLA 2008-06-20 04:52:52 EDT
we need add a render option about the DPI, it is used to convert the px to pt in PDF. The user should set it same with the screen DPI used to design the image.

Comment 3 Gary Xue CLA 2008-06-20 12:29:58 EDT
Hello submitter - can you please attach a copy of the png file that you used to reproduce this issue? 
Comment 4 hgk CLA 2008-06-20 13:13:34 EDT
Created attachment 105517 [details]
png file

The png file size is (width 470px, height 290px)
Comment 5 Yu Chen CLA 2008-06-30 04:27:19 EDT
ENGINE has add a render option about the DPI. 
Can VIEWER get the client screen DPI and send it to ENGINE?
Comment 6 Wenfeng Li CLA 2008-06-30 17:53:58 EDT
(In reply to comment #5)
> ENGINE has add a render option about the DPI. 
> Can VIEWER get the client screen DPI and send it to ENGINE?

It should be the designer to set the DPI to the image report item definition, not the viewer.  Engine can pick up the DPI from image report item property.  Do we need model to add DPI property for image?  
Comment 7 Wei Yan CLA 2008-06-30 23:58:02 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > ENGINE has add a render option about the DPI. 
> > Can VIEWER get the client screen DPI and send it to ENGINE?
> 
> It should be the designer to set the DPI to the image report item definition,
> not the viewer.  Engine can pick up the DPI from image report item property. 
> Do we need model to add DPI property for image?  
> 

both the designer and the viewer should set the DPI for ENGINE. The designs defines the DPI used in the design time while the viewer set the DPI uses to render the report.

we have following DPIs:

DESIGN DPI: the DPI setted by the designer, it can be a integer value or ZERO.

VIEW DPI: the DPI setted by the viewer, it can be a integer value or ZERO.

IMAGE DPI: the DPI defined in the image itself, it is a property in the image header, it can be a integer value of ZERO.

IMAGE ITEM DPI: the DPI defined in the image item, it is defined in the design. It can be a integer value or ZERO or "AUTO". which means use the IMAGE DPI.

In design time, the designer should:
1. Define the DPI in the report design, It is used to calculate the physical size in px.

2. When user insert a image, if image have IMAGE DPI setting, the designer should use the IMAGE DPI to calculate the image size and set it on the image item.

3. If the image has no IMAGE DPI the designer should use the DESIGN DPI to calculate the size and set it on the image item.

4. For all images, the user can also set IMAGE ITEM DPI on the item. The IMAGE ITEM DPI setting is used to calculate the image size if the user can't define the size at design time. It is useful for URL image or EXPR image.

In render time, the viewer should set a VIEWER DPI in IRenderOption, it is used to convert design time px size to render time size.

1. for images with physical size, use it directly.
2. for size with PX, calculate the size as:  SIZE * DESIGN_DPI / VIEW_DPI.
3. For any image without size, get the DPI setting through the following sequence:
  a. the IMAGE ITEM DPI setting on the image item.
  b. if the IMAGEITEM DPI is "AUTO", use the IMAGE DPI.
  c. Use the DESIGN DPI.
  d. use the VIEW DPI.
  e. default DPI (72DPI)

calculate the image size as:
  pixels_in_image / DPI.

For some output (such as HTML), if it is hard to get the IMAGE DPI, we can totally ignore the step (b).

Comment 8 Zhiqiang Qian CLA 2008-07-01 01:43:14 EDT
Currently viewer already passes the dpi setting to engine:

http://127.0.0.1:51713/viewer/preview?__report=D%3A%5CWork%5Cruntime-workbench-workspace%5Cbug%5CCrosstab_Script.rptdesign&__format=pdf&__svg=true&__locale=en_US&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=D%3A%5CWork%5Cruntime-workbench-workspace%5Cbug&__dpi=96&-378782250

though the key name is EngineConstants.APPCONTEXT_CHART_RESOLUTION, it's passed to all extended items. but I'm not sure if engine will use this for image item as well.

We may add a DPI property on ReportDesignHandle, this value can be used as default if viewer doesn't pass the setting. But one behavior is, if user copy this design to another desktop with different dpi setting, should the preview generate the report with local desktop setting or design setting? And as viewer always read current desktop setting and pass it to engine, seems this property doesn't have much use.

Regarding the Image item dpi, I think we should always use the original dpi setting from image. It's obscure to allow user to change the dpi for an image. The only benefit to having a dpi property set by designer that I can think of is for run-time performance optimization. Also designer cannot always get the correct dpi from image item(i.e. dynamic url, image from DB), in this case, engine still need to scan the image data. 
Comment 9 Wenfeng Li CLA 2008-07-01 19:43:00 EDT
Wei's solution is very flexible, but I am afraid requiring all report viewer to set DPI will make engine API too difficult to use.   I suggest we make it optional.

To summarize what Wei suggest and Zhiqiang's proposed modification

1. for images with physical size, use it directly.

2. for image size propert set in px and a design DPI property is set to a value (not auto) on the image, calculate the size as:  SIZE / DESIGN_DPI.

3. for image size propert set in px and a design DPI property is set to AUTO on the image, decide DPI with following sequence:
  a. Get the DPI from image data's header
  b. DPI on the report design root handle (need to add a IMage DPI property on report design handle)
  c. Render task option of Image DPI if it is set (need to add a Image DPI setting on render task option)

  d. 72DPI.
  
  calculate the image size as:
  px / DPI.

With this modification, BIRT bundled sample viewer should NOT need to set DPI.  3(b) and 3(c) is only for those special report design or applications that need to control the DPI of image items when the item itself has not set DPI property, nor the image data contains DPI info.

So changes are NOT needed in viewer.  There should be changes in engine. model, and designer only.
Comment 10 Gang Liu CLA 2008-09-16 01:20:19 EDT
Need more time to resolve this bug. 
Suggest moving to next release.
Comment 11 Wei Yan CLA 2008-11-06 00:07:35 EST
defer to 2.5.0 so we can resolve it with several other DPI issues.
Comment 12 Nick P. CLA 2008-11-22 03:08:36 EST
Where is the development roadmap listed?  

I would also like to see this bug fixed.

Thanks
Comment 13 Wenfeng Li CLA 2008-12-08 18:09:37 EST
(In reply to comment #12)
> Where is the development roadmap listed?  
> I would also like to see this bug fixed.
> Thanks

Please check http://wiki.eclipse.org/BIRT_Project_Plan for latest plan.
Comment 14 Yu Chen CLA 2009-02-01 04:14:44 EST
Assign to Model team for adding:
design DPI property on image item,
and image DPI property on report design handle.
Comment 15 Yu Chen CLA 2009-02-01 04:16:28 EST
*** Bug 237426 has been marked as a duplicate of this bug. ***
Comment 16 Rick Lu CLA 2009-02-01 22:06:42 EST
(In reply to comment #14)
> Assign to Model team for adding:
> design DPI property on image item,
> and image DPI property on report design handle.
> 

Please refer to 260350. Properties have been added.
Comment 17 Yu Chen CLA 2009-02-02 22:25:53 EST
To be compatible with web browser, the 3.d default DPI is set to 96.

Fixed.
Comment 18 Tianli Zhang CLA 2009-02-04 05:11:59 EST
First we use the default DPI from image header, and if it hasn't DPI setting, user can specify Image DPI property on report design, if the image hasn't default DPI or DPI on the report design root handle, we set a default 96DPI. Verified in 2.5.0 v20090204-0630 build. Mark as verified.
Comment 19 Yu Chen CLA 2009-02-20 03:38:50 EST
*** Bug 261220 has been marked as a duplicate of this bug. ***