Hello to all,
I am trying to use ogl to select a subregion of an image and clip it.
Basically I want to put a movable, resizable, rotatable rectangle on a
photo, and extract the subimage selected by the bounding box of the
rectangle. This is to be able to crop to the interesting part of a
photo.
However, I saw that even if there is a Rotate method in OGL, it is not
implemented, or at least only for the polygon shape ! Or I am missing
something there ?
Secondly I saw that OGL doesnt allow to put it in top of a wxBitmap or
whatever holding another thing than a background colour. I could
modify this by changing the OnPaint method of the ShapeCanvas class.
This is the quick change I did:
# START new onpaint methid for shapecanvas
def OnPaint(self, evt):
dc = wx.PaintDC(self)
self.PrepareDC(dc)
try:
# try getting a bitmap from the parent object
bitmap = self.parent.GetBitmap()
dc.Clear()
dc.DrawBitmap(bitmap, 0, 0, False)
except:
# fallback to set a background colour
dc.SetBackground(wx.Brush(self.GetBackgroundColour(),
wx.SOLID))
dc.Clear()
if self.GetDiagram():
self.GetDiagram().Redraw(dc)
# STOP new onpaint methid for shapecanvas
However the PolygonShape is not good for the job, because it preserves
the width/height ratio so even if I do a 4-point polygon to emulate a
rectangle, I wont be able to resize only width or only height.
Another problem I found is I try to bind the keyboard events, because
I want to bind the 'r' and 'R' keys to do a Rotate (clockwise and
counter-clockwise) but OGL doesnt seem to handle the keyboard events.
So if someone could only help me a bit ? Or maybe tell me if there is
an alternative to OGL ? I would be very grateful.
Thank you,