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 

Copy a region of an image x,y,w,h / s,t,r


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Steal
User


Joined: 26 Jan 2017
Posts: 72

PostPosted: Tue Feb 27, 2018 11:40 am    Post subject:
Copy a region of an image x,y,w,h / s,t,r
Reply with quote

Hi,

I want to load an image and then cut a region of that loaded image (1) and turn it into another image (2).

I don't understand the s_offset, t_offset and r_offset convention. Can you explain me what that is? I've tried to Google it.

tl;dr...I think copySubImage is what I want, but I don't understand the parameters.

Thank you!

Cheers,
Johny
Back to top
View user's profile Send private message
Steal
User


Joined: 26 Jan 2017
Posts: 72

PostPosted: Tue Feb 27, 2018 12:00 pm    Post subject:
Reply with quote

Hi,

Okay I found this in the docs

int s () const
Width of image.
int t () const
Height of image.
int r () const
Depth of image.

However, the word Depth refers me to an osg class, which is like an enum / util thing or a state attribute of sorts.

How can I specify x,y,w,h instead?

Thank you!

Cheers,
Johny
Back to top
View user's profile Send private message
Steal
User


Joined: 26 Jan 2017
Posts: 72

PostPosted: Sat Mar 03, 2018 12:52 pm    Post subject:
soz bump
Reply with quote

Hi,

My question is: How do I copy a part of an image?

Thanks for reading

- John
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 471
Location: France

PostPosted: Sat Mar 03, 2018 2:33 pm    Post subject:
Re: soz bump
Reply with quote

Hi Steal,
http://forum.openscenegraph.org/viewtopic.php?t=7810&highlight=GLU
All image manipulation methods are GLU based, which require a proper GL context to be created and made current.
Perhaps popping a dummy osgViewer before calling these methods should do the trick...
Cheers

Steal wrote:
Hi,

My question is: How do I copy a part of an image?

Thanks for reading

- John
Back to top
View user's profile Send private message Visit poster's website
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 471
Location: France

PostPosted: Sat Mar 03, 2018 2:46 pm    Post subject:
Re: soz bump
Reply with quote

lol
I posted without reading the post I refer to ...
In theory glu has been reimplemented so it doesn't require a context to be bound anymore
Give us a sample code, it's strange this feature doesn't work...
Edit: I've read the source there's not a chance copySubImage works to copy a part of an image to an other image: offset addresses a destoffset. I think this func may be usefull in the context of mips generation or other interpolation stuff but not for subimage extraction.
I'm afraid you'll have to do that by hand..
If you don't have to do real copy you can do that
Code:
   //  assign the appropriate portion data from the originalImage
        subImage->setImage(originalImage->s()-offsetx, originalImage->t()-offsety, originalImage->r()-offsetz, //
                           originalImage->getInternalTextureFormat(), // same internal texture format
                           originalImage->getPixelFormat(),originalImage->getDataType(), // same pixel foramt and data type
                           originalImage->data(offsetx,offsety,offsetz), // offset the start point
                           osg::Image::NO_DELETE, // don't attempt to delete the image data, leave this to the originalImage
                           originalImage->getPacking(), // use the same packing
                           originalImage->s()); // use the width of the original image as the row width

but images will share some common data which might be undesired..

mp3butcher wrote:
Hi Steal,
http://forum.openscenegraph.org/viewtopic.php?t=7810&highlight=GLU
All image manipulation methods are GLU based, which require a proper GL context to be created and made current.
Perhaps popping a dummy osgViewer before calling these methods should do the trick...
Cheers

Steal wrote:
Hi,

My question is: How do I copy a part of an image?

Thanks for reading

- John
Code:
Back to top
View user's profile Send private message Visit poster's website
minghia
Appreciator


Joined: 12 Dec 2011
Posts: 109
Location: Sydney, Australia

PostPosted: Sun Mar 04, 2018 2:19 am    Post subject:
Reply with quote

Hi,
Does the code in the osghud.cpp examples help?



Cheers,
Tony

_________________
Tony V
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General 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 Image containing floats ivar General 1 Thu Sep 20, 2018 9:18 am View latest post
No new posts minor change: move assumeSizedInterna... mp3butcher General 9 Wed Aug 15, 2018 10:07 pm View latest post
No new posts Drawing a partially transparent image... Jose Pedro Canilho General 6 Mon Jul 02, 2018 9:28 am View latest post
No new posts Strange behaviour on GBufferCamera wi... wernerM General 5 Wed Jun 27, 2018 12:53 pm View latest post
No new posts Image getColor not implemented for GL... Tare General 3 Fri May 18, 2018 11:24 am 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