Load, display, process and save an image with wxWidgets

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
bertolino
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 14, 2013 8:07 am
Location: France
Contact:

Load, display, process and save an image with wxWidgets

Postby bertolino » Thu Aug 29, 2013 5:06 pm

Here is a small self-sufficient piece of code that shows how to deal with image files:
load the image, display it, process it (I mean modify the pixels the way you like) and then save it.
It can easily be extended to deal with many image processing.
The code is just one file with some comments.
Enjoy.

Pascal
Attachments
bertimage.cpp
source code of bertimage
(11.5 KiB) Downloaded 355 times

User avatar
doublemax
Moderator
Moderator
Posts: 12882
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Load, display, process and save an image with wxWidgets

Postby doublemax » Thu Aug 29, 2013 5:53 pm

Thanks for sharing.

But a small advice: Converting the raw data to a wxImage and then to wxBitmap on each paint event is very inefficient and will lead to a noticeable slowdown with bigger images. You should keep a wxBitmap for display at all times and only update it when the image data changes.
Use the source, Luke!

bertolino
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 14, 2013 8:07 am
Location: France
Contact:

Re: Load, display, process and save an image with wxWidgets

Postby bertolino » Fri Aug 30, 2013 7:07 am

doublemax wrote:Thanks for sharing.

But a small advice: Converting the raw data to a wxImage and then to wxBitmap on each paint event is very inefficient and will lead to a noticeable slowdown with bigger images. You should keep a wxBitmap for display at all times and only update it when the image data changes.

Thanks for your advice. You're totally right. I will update the code soon to improve that.


Return to “The Code Dump”

Who is online

Users browsing this forum: No registered users and 3 guests