wxOGL wx.ShapeCanvas 图像

发布于 2024-10-19 15:06:11 字数 104 浏览 5 评论 0原文

我正在使用 wxPython ogl.ShapeCanvas 制作一个小型照片编辑应用程序。我可以在画布上加载图像。我只想知道如何调整画布内图像的亮度/对比度(使用滑块)。

谢谢

I am making a small photo editing application using wxPython ogl.ShapeCanvas. I can load images on the canvas. I just want to know how will I adjust the brightness/contrast of an image inside the canvas (using a slider).

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

超可爱的懒熊 2024-10-26 15:06:11

希望现在能提供任何帮助还不算太晚,但是......最近当我想动态调整透明度时,我不得不使用 OGL 做类似的事情。我最终做的是创建一个进行调整并返回 wx.Bitmap 的类,然后我有一个 ShapeCanvas 子类使用调整后的图片,例如,

class PicAdjuster(cls):    
    def adjust_pic(self, image_filename, factor_red = 1., factor_green = 1., factor_blue = 1., factor_alpha = 1.):
        original_img = wx.Image(image_filename)
        adjusted_img = original_img.AdjustChannels(factor_red, factor_green, factor_blue, factor_alpha)
        return wx.BitmapFromImage(adjusted_img)

然后对于 ShapeCanvas:

class PicDisplay(ogl.ShapeCanvas):
    def add_picture(self, image_filename):
        new_img = ogl.BitmapShape()
        add_alpha = PicAdjuster()
        new_img.SetBitmap(add_alpha.adjust_pic(factor_alpha = 0.5))
        self.diagram.AddShape(new_img)

无论如何,您也许可以做类似的事情来使您的调整;只需使用图片调整器并根据需要调用 ogl.BitmapShape 的 SetBitmap() 方法即可。

Hope it's not to late to be of any help, but...I had to do something similar with OGL recently when I wanted to adjust the transparency on the fly. What I ended up doing was creating a class that made the adjustments and returned a wx.Bitmap, then I had a ShapeCanvas subclass use the adjusted picture, e.g.

class PicAdjuster(cls):    
    def adjust_pic(self, image_filename, factor_red = 1., factor_green = 1., factor_blue = 1., factor_alpha = 1.):
        original_img = wx.Image(image_filename)
        adjusted_img = original_img.AdjustChannels(factor_red, factor_green, factor_blue, factor_alpha)
        return wx.BitmapFromImage(adjusted_img)

then for the ShapeCanvas:

class PicDisplay(ogl.ShapeCanvas):
    def add_picture(self, image_filename):
        new_img = ogl.BitmapShape()
        add_alpha = PicAdjuster()
        new_img.SetBitmap(add_alpha.adjust_pic(factor_alpha = 0.5))
        self.diagram.AddShape(new_img)

Anyway, you might be able to do something similar to make your adjustments; just use your picture adjuster and call the ogl.BitmapShape's SetBitmap() method as required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文