View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014397VTK(No Category)public2013-11-06 10:272014-10-02 16:59
ReporterJoseph Ott 
Assigned ToCory Quammen 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version5.10.1 
Target VersionFixed in Version6.2.0 
Summary0014397: vtkBMPReader computes wrong header (data offset) for BMP file generated by Photoshop
DescriptionWhen reading a 256 color (8 bit)BMP file generated by Photoshop the image is shifted by two bytes.

During debug inspection of the header size returned by vtkBMPReader::GetHeaderSize() showed that vtkBMPReader returned a header size of 1080 instead of the expected 1078.

Inspection of image data showed that vtkBMPReader started reading the image data at offset 1080 instead of 1078.

Using vtkBMPReader::SetHeaderSize(1078) correctly reads the image.

The data offset value within the BMP file is 1078, so not sure why vtkBMPReader::GetHeaderSize() is reporting 1080.

NOTE: This may be the underlying issue for bug 0013495

The BMP file used in testing is attached.

As a work around when reading BMP files I check the header size and if the header size is reported as 1080 I use SetHeaderSize to set it to 1078. Not the best solution, but since 1080 is an invalid header size for the supported BMP formats it should have no ill effects.




TagsNo tags attached.
ProjectTBD
Typeincorrect functionality
Attached Files? file icon Test_page.bmp [^] (790,080 bytes) 2013-11-06 10:27

 Relationships

  Notes
(0031842)
Joseph Ott (reporter)
2013-11-06 11:13

As a quick test I opened the test image in paint and saved it. The header size was correctly reported on the new test image. I looked at the file size and noticed that the file saved from Photoshop was 2 bytes bigger than that saved by Paint.

I inspected the code vtkImageReader2::GetHeaderSize() and realized that the header size is computed from the file size and not based on the data offset read from the BMP file.

With Photoshop adding 2 bytes to the BMP file this is causing the wrong header size to be reported.

Would a potential solution be to have the vtkBMPReader class call SetHeaderSize with the data offset value read in from the file? This does not change the base class, but allows the BMP file to use the header size found within the file.
(0033518)
Cory Quammen (developer)
2014-10-02 15:06

I observed the problem with the below test code:

#!/usr/bin/env python
import vtk

# this test is designed to check the operation of the 8bit
# export of BMPs
# Image pipeline
reader = vtk.vtkBMPReader()
reader.SetFileName("Test_page.bmp")
reader.SetAllow8BitBMP(1)
map = vtk.vtkImageMapToColors()
map.SetInputConnection(reader.GetOutputPort())
map.SetLookupTable(reader.GetLookupTable())
map.SetOutputFormatToRGB()
viewer = vtk.vtkImageViewer2()
viewer.SetInputConnection(map.GetOutputPort())
viewer.SetColorWindow(256)
viewer.SetColorLevel(127.5)

#viewer.Render()
iren = vtk.vtkRenderWindowInteractor()
viewer.SetupInteractor(iren)
viewer.Render()
viewer.GetRenderer().ResetCamera()
iren.Initialize()
viewer.Render()
iren.Start()
(0033520)
Cory Quammen (developer)
2014-10-02 15:09

http://review.source.kitware.com/#/c/17354/ [^]
(0033545)
Cory Quammen (developer)
2014-10-02 16:59

commit 8f3d921fc4c20cd02e356211d1ef5f6159c491d2
Author: Cory Quammen <cory.quammen@kitware.com>
Date: Thu Oct 2 14:58:31 2014 -0400

    BUG: Fixed how the header size is computed
    
    The header size is written to a header field that was being ignored by
    the reader. The header size was being computed as the difference of
    the size of the file on disk and the size of the image data in memory,
    but if the writer of the BMP adds bytes after the image data portion
    of the file, this size is inaccurate. This patch trusts the header
    size in the file rather than the computed header size.
    
    Change-Id: I910559c7f014af5e2ccb73cb0624f5a9782c0ea9

 Issue History
Date Modified Username Field Change
2013-11-06 10:27 Joseph Ott New Issue
2013-11-06 10:27 Joseph Ott File Added: Test_page.bmp
2013-11-06 11:13 Joseph Ott Note Added: 0031842
2014-10-02 14:38 Cory Quammen Assigned To => Cory Quammen
2014-10-02 14:38 Cory Quammen Status backlog => active development
2014-10-02 15:06 Cory Quammen Note Added: 0033518
2014-10-02 15:09 Cory Quammen Note Added: 0033520
2014-10-02 15:09 Cory Quammen Status active development => gerrit review
2014-10-02 16:59 Cory Quammen Note Added: 0033545
2014-10-02 16:59 Cory Quammen Status gerrit review => closed
2014-10-02 16:59 Cory Quammen Resolution open => fixed
2014-10-02 16:59 Cory Quammen Fixed in Version => 6.2.0


Copyright © 2000 - 2018 MantisBT Team