About Store Forum Documentation Contact
Donations:
158$/mo



Post Reply 
Editing a texture in EE
Author Message
Zervox Offline
Member

Post: #1
Editing a texture in EE
I am trying to edit a texture with adding points to the image, everything in my program are inside one EE::Window, in which they are separated by several Regions, I was curious if anyone knows how I can map the screen coordinates to the GuiImage's imageptr, I need them to be mapped exactly where they are placed on the screen onto the texture/image no matter the image's true resolution

   
(This post was last modified: 01-19-2013 03:33 PM by Zervox.)
01-19-2013 03:30 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Editing a texture in EE
Some helpful hints:

Code:
Rect_LU image_screen_rect(gui_image.screenPos(), gui_image.size());

Vec2 PosToPixel(C Vec2 &local_pos) // convert position in 'gui_image' object local space to 'image' pixel
{
   return local_pos*Vec2(image.x(), image.y())/gui_image.size(); // here you may need to check output "y" to "image.y()-y"
}

It will be better if you draw things on top of the image, and not editing EE::Image realtime.
01-19-2013 10:06 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #3
RE: Editing a texture in EE
I am drawing the points directly on screen I only do a check if I my Ms.pos is inside the ImageRegion, the points are still added through Ms.pos so I guess I will need to add screen pos translation for every window rectangle as to where I am adding these points?

I need to finally add them to the image as I need be able to post them as external images, and the resolution of every image is not guaranteed to be of the same size according to the GuiRegion.

You wouldn't by chance know of a good way to add points inside the gui objects so that the image rectangle could be expanded and I could use the region around the image to "scroll" the image like a zoom function? eg the points will be at the placed position according to image scale as well?


Code:
Gui+=win.create(Rect_LU(-D.w(),  D.h(), D.w()+D.w(), D.h()+D.h())).barVisible(false).visible(true);

win+=NamesRegion.create(Rect_LU(0,0,0.4,win.rect.h()));
NamesRegion+=NameList.create(NameListColumn, Elms(NameListColumn)).setData(NameArr);

win+=MapRegion.create(Rect_RU(win.crect.w(),0, 0.5f, 1.38f));
MapRegion+=MapsList.create(MapListColumn, Elms(MapListColumn)).setData(MapsArr);

win+=ImageRegion.create(Rect_LU(NamesRegion.rect.w(),0,MapRegion.pos().x-(MapRegion.rect.w()/1.25),win.rect.h()/1.44));
ImageRegion+=GWImage.create(Rect_LU(0,0,ImageRegion.rect.w(),ImageRegion.rect.h(​)),&WImage);

if(Ms.bp(0)&& Gui.ms()==&bgui.GWImage){points.New()=Ms.pos();}
(This post was last modified: 01-20-2013 02:31 AM by Zervox.)
01-19-2013 11:49 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: Editing a texture in EE
Ok, the functions worked, thanks Greg!

Code:
Vec2 PosToPixel(C Vec2 &local_pos) { // convert position in 'gui_image' object local space to 'image' pixel
   return local_pos*Vec2(image.x(), image.y())/gui_image.size();
}

Rect_LU image_screen_rect(gui_image.screenPos(), gui_image.size());
Vec2 temp=image_screen_rect.center()-Ms.pos();
temp=PosToPixel(temp);
temp.x=-temp.x;
temp+=Vec2(image.x()/2,image.y()/2);
This way the pixels didn't go from -256 to 256 on a 512x512 but 0,0 to 512,512

Another question in regards to this, it wouldn't be possible to get rendered images rendered properly into the texture? I want to mesh the drawn images on screen rendered properly into the texture.

or an easier way than to individually map each of my points, because each point has images that are drawn on screencoordinates and I need their images pixels being draw with how they look because of their alpha map and drawMask changes(color changes) to the texture.

Code:
img = "LocalData/Icons/ALL.gfx";
imgm = "LocalData/Icons/ALLM.gfx";
Rect d(pts[i].p-0.02,pts[i].p+0.02);
Images(img)->drawMask(WHITE,pts[i].c,rect,*Images(imgm), rect);
(This post was last modified: 01-21-2013 01:29 AM by Zervox.)
01-21-2013 01:15 AM
Find all posts by this user Quote this message in a reply
Post Reply