OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

bmp load vertically flipped


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Plugins [osgPlugins]
View previous topic :: View next topic  
Author Message
stefanix
User


Joined: 09 Jun 2009
Posts: 49
Location: nyc

PostPosted: Thu Sep 03, 2009 12:04 pm    Post subject:
bmp load vertically flipped
Reply with quote

Hi,

I have been doing some image stuff lately. JPEGs and PNGs load right but
BMPs are upside down. Is this a feature or a bug?

At the moment I am doing this for remedy:
Code:

    osg::Image* image = osgDB::readImageFile(filename);
    if(filename.substr(filename.length()-3) == "bmp") {
        image->flipVertical();
    }



Just thought I share this.

Thank you!

Cheers,
stefan

_________________
stefan hechenberger

http://linear.nortd.com
Back to top
View user's profile Send private message
Ulrich Hertlein
Guest





PostPosted: Thu Sep 03, 2009 2:02 pm    Post subject:
bmp load vertically flipped
Reply with quote

Hi Stefan,

On 3/09/09 2:04 PM, stefan nortd wrote:
Quote:
I have been doing some image stuff lately. JPEGs and PNGs load right but
BMPs are upside down. Is this a feature or a bug?

I believe the problem with BMPs is that they don't define an 'up' direction.
It's up to the originating modelling package how it's stored. The loader doesn't try to
fix what it doesn't know.

Cheers,
/ulrich


------------------
Post generated by Mail2Forum
Back to top
stefanix
User


Joined: 09 Jun 2009
Posts: 49
Location: nyc

PostPosted: Thu Sep 03, 2009 3:14 pm    Post subject:
Reply with quote

hey ulrich,

I am not sure I understand. I am loading a bmp and use it as a texture on a quad. I use the same texture coordinates for various image types but only the bmp displays upside down.

stefan

_________________
stefan hechenberger

http://linear.nortd.com
Back to top
View user's profile Send private message
Ulrich Hertlein
Guest





PostPosted: Thu Sep 03, 2009 3:40 pm    Post subject:
bmp load vertically flipped
Reply with quote

Hi Stefan,

On 3/09/09 5:14 PM, stefan nortd wrote:
Quote:
I am not sure I understand. I am loading a bmp and use it as a texture on a quad. I use
the same texture coordinates for various image types but only the bmp displays upside
down.

Then I would say your BMP is upside down ;-)

I have a stack of objects with BMP textures that would definitively look wrong if the
loader would always flip the image. It's all down to how it was modelled.

Cheers,
/ulrich


------------------
Post generated by Mail2Forum
Back to top
Ryan.H.Kawicki (Ryan H. Kawicki)
User


Joined: 21 Jul 2009
Posts: 24

PostPosted: Thu Sep 03, 2009 3:48 pm    Post subject:
bmp load vertically flipped
Reply with quote

Bitmaps are stored upside down internally. If the loader is not
flipping your image, then flip the image yourself.

Quote:
From "http://en.wikipedia.org/wiki/BMP_file_format"
Bitmap data

This block of bytes describes the image, pixel by pixel. Pixels are
stored "upside-down" with respect to normal image raster scan order,
starting in the lower left corner, going from left to right, and then
row by row from the bottom to the top of the image.[2] Uncompressed
Windows bitmaps can also be stored from the top row to the bottom, if
the image height value is negative.

Ryan H. Kawicki
The Boeing Company
Training Systems & Services
Software Engineer

g


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ulrich Hertlein
Guest





PostPosted: Thu Sep 03, 2009 4:02 pm    Post subject:
bmp load vertically flipped
Reply with quote

On 3/09/09 5:47 PM, Kawicki, Ryan H wrote:
Quote:
Bitmaps are stored upside down internally. If the loader is not
flipping your image, then flip the image yourself.

Quote:
From "http://en.wikipedia.org/wiki/BMP_file_format"
Bitmap data

This block of bytes describes the image, pixel by pixel. Pixels are
stored "upside-down" with respect to normal image raster scan order,
starting in the lower left corner, going from left to right, and then
row by row from the bottom to the top of the image.[2] Uncompressed
Windows bitmaps can also be stored from the top row to the bottom, if
the image height value is negative.

Ah, good point. The loader actually checks for negative height values and corrects them.
Which means it's flipping the image but not exposing this information.

/ulrich


------------------
Post generated by Mail2Forum
Back to top
stefanix
User


Joined: 09 Jun 2009
Posts: 49
Location: nyc

PostPosted: Thu Sep 03, 2009 7:32 pm    Post subject:
Reply with quote

Granted that different image types store pixels differently I would still
assume that the image loader should nevertheless be consistent across different image format. I guess this is an assumption that depends how low-level one approaches pixel data.

So I record it is not a bug in the image loader. correct?

Thank you!

Cheers,
stefan

_________________
stefan hechenberger

http://linear.nortd.com
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Thu Sep 03, 2009 8:35 pm    Post subject:
bmp load vertically flipped
Reply with quote

stefan nortd wrote:
Quote:
Granted that different image types store pixels differently I would still
assume that the image loader should nevertheless be consistent across different image format. I guess this is an assumption that depends how low-level one approaches pixel data.

Agreed.

Quote:
So I record it is not a bug in the image loader. correct?

It could be a bug, or it could be a bug in whatever created the BMP. Do we have sample
data that we can look at? I know the BMP format pretty well.

--
Chris 'Xenon' Hanson, omo sanza lettere Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen


------------------
Post generated by Mail2Forum
Back to top
Ulrich Hertlein
Guest





PostPosted: Fri Sep 04, 2009 8:46 am    Post subject:
bmp load vertically flipped
Reply with quote

On 3/09/09 9:32 PM, stefan nortd wrote:
Quote:
Granted that different image types store pixels differently I would still assume that
the image loader should nevertheless be consistent across different image format. I
guess this is an assumption that depends how low-level one approaches pixel data.

So I record it is not a bug in the image loader. correct?

Agreed, it's not a bug but a missing feature.

Could you run your code with OSG_NOTIFY_LEVEL=DEBUG_INFO and grep the output for 'BMP
Image is upside-down' (which indicates 'height<0')?

The models I have do not have negative height so if your BMP does we could expose it and
flip the Image automatically.

Cheers,
/ulrich


------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Plugins [osgPlugins] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts 回复: Is it possible to load text... GarfieldPig General 118 Fri May 10, 2019 4:32 pm View latest post
No new posts Is it possible to load texture withou... robertosfield General 9 Thu May 09, 2019 8:29 pm View latest post
No new posts Is it possible to load texture withou... DrPowers General 0 Thu May 09, 2019 3:30 pm View latest post
No new posts Is it possible to load texture withou... DrPowers General 0 Thu May 09, 2019 3:29 pm View latest post
No new posts Is it possible to load texture withou... DrPowers General 0 Thu May 09, 2019 3:23 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP