How do you update an existing (displayed) image?

116 views
Skip to first unread message

Jim Graham

unread,
Mar 21, 2015, 5:34:12 PM3/21/15
to fltkg...@googlegroups.com
I have an image converted from an OpenCV Mat displayed in an
Fl_PNG_Image. I'm trying to update the image, after a simple conversion
to grayscale, by using:

image[fn] = new Fl_PNG_Image(fn.c_str(), buff, tsize);
box[fn]->image(image[fn]);
win[fn]->show();

instead of

win[fn] = new Fl_Window(imgW[fn],imgH[fn]);
win[fn]->label(sfn);
box[fn] = new Fl_Box(0,0,imgW[fn],imgH[fn]);
image[fn] = new Fl_PNG_Image(fn.c_str(), buff, tsize);
box[fn]->image(image[fn]);
win[fn]->show();

Unfortunately, the new grayscale image doesn't load at all. I have
tested it down to this point. If I call the second version to just
load a new image, it works, and loads the grayscale version. Trying to
merely update the image does not work---the grayscale image isn't loaded
at all, and the original remains in the Fl_Window.

How do I update an image that's already displayed?

NOTE: I've limited the code to the above, because that's the only
difference between the two steps, and I'm just trying to keep it simple.
If full code is still needed, just ask.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) | AN EXCERCISE is a situation in which you stop what
spook...@gmail.com | you're doing in order to simulate doing what you
< Running Mac OS X Lion > | were doing so you can show someone else that you
ICBM / Hurricane: | can simulate what you were doing as well as you
30.44406N 86.59909W | were doing it before you were interrupted.
http://fineartamerica.com/profiles/4-james-graham.html

Jim Graham

unread,
Mar 21, 2015, 11:05:13 PM3/21/15
to fltkg...@googlegroups.com
Ok, even I'm not satisfied now with the code extracts I posted. So
here's the whole test app.

--------------------------- CUT HERE ---------------------------
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Image.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_RGB_Image.H>
#include <FL/Fl_PNG_Image.H>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <map>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/types_c.h"
#include <FL/fl_draw.H> // not sure if I need this

using namespace cv;
using namespace std;

void show_image(unsigned char *buff, unsigned long tsize, string fn);
// Comment: the exact same function call, using the exact same prototype
// (except for the function name itself) fails as not valid. WTFO?

// Globals

Mat t;

map<int, string> imgFilename;
map<string, int> imgW;
map<string, int> imgH;
map<string, Fl_PNG_Image*> image;
map<string, Fl_Box*> box;
map<string, Fl_Window*> win;
int idx = 0;


void window_cb(Fl_Widget* w, void*) {
((Fl_Double_Window *)w)->hide();
}


int streq(string s1, string s2) {
const char* ts1 = s1.c_str();
const char* ts2 = s2.c_str();
if (strcmp(ts1, ts2) == 0) return 1;
return 0;
}


void load_image(Mat t, string fn) {
const char* sfn = fn.c_str(); // Fl_window needs const char *
int fileAlreadyLoaded = 0;
idx += 1;
for (int i=0; i<idx; ++i) {
if (streq(fn, imgFilename[i])) {
fileAlreadyLoaded = 1;
idx -= 1;
} else {
imgFilename[idx] = fn;
}
}
imgW[fn] = t.cols;
imgH[fn] = t.rows;
vector<uchar> tbuff;
vector<int> param = vector<int>(2);

param[0]=CV_IMWRITE_PNG_COMPRESSION;
param[1]=0; //default(3) 0--9.

imencode(".png", t, tbuff, param);
unsigned char *buff = tbuff.data();
unsigned long tsize = tbuff.size();
if (fileAlreadyLoaded) {
image[fn] = new Fl_PNG_Image(fn.c_str(), buff, tsize);
box[fn]->image(image[fn]);
win[fn]->show();
} else {
show_image(buff, tsize, fn);
}
}


void show_image(unsigned char *buff, unsigned long tsize, string fn) {
const char* sfn = fn.c_str(); // Fl_window needs const char *
win[fn] = new Fl_Window(imgW[fn],imgH[fn]);
win[fn]->label(sfn);
box[fn] = new Fl_Box(0,0,imgW[fn],imgH[fn]);
image[fn] = new Fl_PNG_Image(fn.c_str(), buff, tsize);
box[fn]->image(image[fn]);
win[fn]->show();
}


int main(int argc, char **argv) {
string fn = "/Users/jim/testimage1.jpg";
Mat t = imread(fn, -1); // -1 loads image as is (with its alpha channel)
load_image(t,fn);

// test updating the same image after modification of the image
// fn = "/Users/jim/testimage2.png";
t = imread(fn, -1); // -1 loads image as is (with its alpha channel)
Mat newMat;
cvtColor(t, newMat, CV_BGR2GRAY);
load_image(newMat,fn); // SHOULD show in the same window
return Fl::run();
}

--------------------------- CUT HERE ---------------------------

The objective here is to update an existing image after it's been
modified via some (any) image processing as a Mat in OpenCV. This test
is meant to apply a one-liner mod and then see if I have a clue how to
update the existing image. Clearly, I don't.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) |
spook...@gmail.com | BOFH Excuse for the day:
< Running Mac OS X Lion > |
ICBM / Hurricane: | Your parity check is overdrawn and
30.44406N 86.59909W | you're out of cache.
http://fineartamerica.com/profiles/4-james-graham.html

Albrecht Schlosser

unread,
Mar 22, 2015, 2:38:29 PM3/22/15
to fltkg...@googlegroups.com
Your code is way too complicated to be very helpful. You should better
make it really simple to test what you need to do before posting your
entire, growing application.

Anyway: please make a small change and a test.

On 22.03.2015 04:05 Jim Graham wrote:

> void show_image(unsigned char *buff, unsigned long tsize, string fn) {
> const char* sfn = fn.c_str(); // Fl_window needs const char *
> win[fn] = new Fl_Window(imgW[fn],imgH[fn]);
> win[fn]->label(sfn);
> box[fn] = new Fl_Box(0,0,imgW[fn],imgH[fn]);
> image[fn] = new Fl_PNG_Image(fn.c_str(), buff, tsize);
> box[fn]->image(image[fn]);

Add here:

win[fn]->resizable(win[fn]);

> win[fn]->show();
> }

The test I want you to do: resize the window when it shows the wrong
(first) image. Does it show the right (modified) window then?

If this works, then try to change this:

> if (fileAlreadyLoaded) {
> image[fn] = new Fl_PNG_Image(fn.c_str(), buff, tsize);
> box[fn]->image(image[fn]);

Add here:

box[fn]->redraw();

> win[fn]->show();

BTW: AFAICT you can remove the above statement.

> } else {
> show_image(buff, tsize, fn);
> }

Does this work? If it doesn't I suggest that you try to use a simple
test case before you try to do more complex things in your application.
We can only help with your code if it is simple enought to understand
easily or use it directly in a test program.

In your case I'd suggest to create a small test program that loads a png
image from disk (the basics are the same as in your app). Add a button
to load another image and see if this works. You know how to write a
callback, and after "loading" the other png image from disk you will
probably have to call redraw() on the box or the entire window. If this
doesn't work we can certainly help better if you post the code of this
test program w/o any other dependencies (e.g. on OpenCV etc.).

PS: You can still use OpenCV to save both images to disk. They should
probably have the same size.

PPS: In your code you "forgot" to delete the old image (memory leak).

Ian MacArthur

unread,
Mar 22, 2015, 5:33:48 PM3/22/15
to fltkg...@googlegroups.com
On Sun Mar 22 2015 03:05:08, Jim Graham wrote:
>
> Ok, even I'm not satisfied now with the code extracts I posted. So
> here's the whole test app.


Jim,

Here’s a simplified version of the how_to that I linked before, that animates the processing of the image and refreshes it dynamically.

It’s far form the ideal solution, but I think it shows what you need... Compile it with:

fltk-config --use-images --compile name.cxx

Then execute it as:

./name some_image.jpg

And let it do its thing... Is that showing what you wanted to do?


/************************************************************************/
// compile as:
// fltk-config --use-images --compile twin_image.cxx
//
// invoke as:
// twin_image somefile.jpg (should work with many image types, jpg, png, etc...)

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Image.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_Button.H>
#include <Fl/fl_draw.H>

Fl_Double_Window *main_win = NULL;
Fl_Shared_Image *img = NULL;
Fl_RGB_Image *img_3 = NULL;

int depth = 0;
int count = 0;
int width = 0;
int height = 0;
const char *datap = NULL;
int xoff = 0;
int yoff = 0;

const double frame_delay = (1.0 / 10.0);

/************************************************************************/
Fl_Box *box_1;
Fl_Box *box_3;

/************************************************************************/
void load_file(const char *n)
{
if (img) img->release();

img = Fl_Shared_Image::get(n);
if (!img) {
puts("Image file format not recognized!");
fflush(stdout);
return;
}
if (img->w() > box_1->w() || img->h() > box_1->h()) {
Fl_Image *temp;
if (img->w() > img->h()) temp = img->copy(box_1->w(), box_1->h() * img->h() / img->w());
else temp = img->copy(box_1->w() * img->w() / img->h(), box_1->h());

img->release();
img = (Fl_Shared_Image *)temp;
}

box_1->image(img);
box_1->redraw();
} // load_file

/************************************************************************/
void quit_cb(Fl_Button *, void *)
{
main_win->hide();
} // quit_cb

/************************************************************************/
void process_cb(void *)
{
unsigned total = width * height * depth;
static char *processed_data = NULL;

if (processed_data == NULL) { // setup processed data
processed_data = new char [total];
for (unsigned idx = 0; idx < total; idx ++)
{
processed_data[idx] = datap[idx];
}
}
else { // process data
for (unsigned idx = 0; idx < total; idx ++)
{
processed_data[idx] = (processed_data[idx] + 3) & 0xFF;
}
}

if (img_3 != NULL) {
delete img_3;
}

img_3 = new Fl_RGB_Image((const uchar *)processed_data, width, height, depth);
box_3->image(img_3);
box_3->redraw();

Fl::repeat_timeout(frame_delay, process_cb);
} // process_cb

/************************************************************************/
int main(int argc, char **argv)
{
fl_register_images();
Fl::get_system_colors();

main_win = new Fl_Double_Window(615, 300);
main_win->begin();

box_1 = new Fl_Box(0, 0, 200, 200);

box_3 = new Fl_Box(410, 0, 200, 200);

Fl_Button *quit = new Fl_Button(540, 260, 60, 30);
quit->label("Quit");
quit->callback((Fl_Callback *)quit_cb);

main_win->end();

if (argv[1]) {
load_file(argv[1]);
}
else {
printf("Need a file ot process\n");
return -1;
}

depth = img->d();
count = img->count();
datap = img->data()[0];
width = img->w();
height = img->h();

if (height < box_1->h()) {
yoff = (box_1->h() - height) / 2;
}

if (width < box_1->w()) {
xoff = (box_1->w() - width) / 2;
}

printf("Depth: %d Count: %d W: %d H: %d\n", depth, count, width, height);
printf("X offs %d Y offs %d\n", xoff, yoff);
fflush(stdout);

main_win->show();

// animate the refresh
Fl::add_timeout(frame_delay, process_cb);

return Fl::run();
} // main

/* End of File */





Jim Graham

unread,
Mar 22, 2015, 5:37:46 PM3/22/15
to fltkg...@googlegroups.com
On Sun, Mar 22, 2015 at 07:38:23PM +0100, Albrecht Schlosser wrote:
> Your code is way too complicated to be very helpful. You should
> better make it really simple to test what you need to do before
> posting your entire, growing application.

That's why I initially just posted the lines that work for the first
image, and the ones that don't for the second (and beyond). I guess
that wasn't such a bad choice after all. And this IS the simple test,
btw. And as for the code being too complicated, I got it from y'all
right here on this list.

> Add here:
>
> win[fn]->resizable(win[fn]);
>
> > win[fn]->show();

First attempt, I expected FLTK to add some kind of tab or something to
grab onto with the mouse to resize it. No dice. So I coded in a
resize. Nothing...didn't even resize.

> PS: You can still use OpenCV to save both images to disk. They should
> probably have the same size.

Yes, I've done that.

> PPS: In your code you "forgot" to delete the old image (memory leak).

I tried that, too. Clearly I did it wrong, because the original image
stayed right where it was.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) |
spook...@gmail.com | BOFH Excuse for the day:
< Running Mac OS X Lion > |
ICBM / Hurricane: | You need to install an
30.44406N 86.59909W | RTFM interface.
http://fineartamerica.com/profiles/4-james-graham.html

Jim Graham

unread,
Mar 22, 2015, 6:03:49 PM3/22/15
to fltkg...@googlegroups.com
On Sun, Mar 22, 2015 at 09:33:45PM +0000, Ian MacArthur wrote:

> Here???s a simplified version of the how_to that I linked before, that
> animates the processing of the image and refreshes it dynamically.

> It???s far form the ideal solution, but I think it shows what you
> need... Compile it with:

> fltk-config --use-images --compile name.cxx

Did that...got a ton of errors---the file didn't come through as plain
text (had all of those =3D and similar. Please attach the file instead
of putting it inline. Perhaps zip it (or use .tar.gz, etc.). That
should keep it clean of all of that. I tried to clean it up, but it
got turned into a mess somewhere in transit.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) |
spook...@gmail.com | BOFH Excuse for the day:
< Running Mac OS X Lion > |

Albrecht Schlosser

unread,
Mar 22, 2015, 7:55:20 PM3/22/15
to fltkg...@googlegroups.com
On 22.03.2015 23:03 Jim Graham wrote:
> On Sun, Mar 22, 2015 at 09:33:45PM +0000, Ian MacArthur wrote:
>
>> Here???s a simplified version of the how_to that I linked before, that
>> animates the processing of the image and refreshes it dynamically.
>
>> It???s far form the ideal solution, but I think it shows what you
>> need... Compile it with:
>
>> fltk-config --use-images --compile name.cxx
>
> Did that...got a ton of errors---the file didn't come through as plain
> text (had all of those =3D and similar. Please attach the file instead
> of putting it inline.

Please see attached file twin_image.cxx.

PS: @Ian: needed one fix in line #18:

-#include <Fl/fl_draw.H>
+#include <FL/fl_draw.H>
twin_image.cxx

Jim Graham

unread,
Mar 22, 2015, 7:57:38 PM3/22/15
to fltkg...@googlegroups.com
On Mon, Mar 23, 2015 at 12:55:14AM +0100, Albrecht Schlosser wrote:
> On 22.03.2015 23:03 Jim Graham wrote:
>
> Please see attached file twin_image.cxx.

Got it.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) |
spook...@gmail.com | BOFH Excuse for the day:
< Running Mac OS X Lion > |
ICBM / Hurricane: | Paradigm shift without
30.44406N 86.59909W | a clutch.
http://fineartamerica.com/profiles/4-james-graham.html

Albrecht Schlosser

unread,
Mar 22, 2015, 8:23:29 PM3/22/15
to fltkg...@googlegroups.com
On 22.03.2015 22:37 Jim Graham wrote:
> On Sun, Mar 22, 2015 at 07:38:23PM +0100, Albrecht Schlosser wrote:
>> Your code is way too complicated to be very helpful. You should
>> better make it really simple to test what you need to do before
>> posting your entire, growing application.
>
> That's why I initially just posted the lines that work for the first
> image, and the ones that don't for the second (and beyond). I guess
> that wasn't such a bad choice after all.

It _was_ a bad choice. Often there are subtle errors in lines you never
thought of (and didn't post). Other problems may not be seen in a few
lines (although they are there) because the context is missing.

> And this IS the simple test,
> btw. And as for the code being too complicated, I got it from y'all
> right here on this list.

Yeah, I know that we helped you to make it work. But it is not a
/simple/ test case. Particularly because OpenCV is involved. If you want
help here it's best to use only FLTK code, reduce the test case to the
minimal program that shows the problem, then post the entire program so
we can compile and run it. Once you see the solution you should be able
to apply it to _your_ program.

BTW: I decided not to install OpenCV because it would have been a very
large install with lots of dependencies. You may say "it's simple", but
that is my decision. Hence I can only help by _looking_ at your code and
guessing. Others may not even take a look because they don't know what
your OpenCV code does.

>> Add here:
>>
>> win[fn]->resizable(win[fn]);
>>
>>> win[fn]->show();
>
> First attempt, I expected FLTK to add some kind of tab or something to
> grab onto with the mouse to resize it. No dice.

If you added the line and compiled your program you should be able to
resize the window by dragging the border.

> So I coded in a
> resize. Nothing...didn't even resize.

That wouldn't help anyway. The point is: if you forgot a 'redraw()' call
somewhere in your code, resizing the window forces FLTK to (re)draw the
entire window. Hence the "right" image would magically appear when
resizing the window.

However, this was only intended as a test. If you add the redraw()
statement as I posted previously the window would also appear - if I
understood your example code and found the issue by /reading/ the code.
I don't know if that was really the point. That's why we need pure FLTK
code to compile and test if we want to help you more efficiently.

>> PPS: In your code you "forgot" to delete the old image (memory leak).
>
> I tried that, too. Clearly I did it wrong, because the original image
> stayed right where it was.

Not necessarily. delete doesn't always clear or overwrite the memory
that was occupied by the object. Hence it can still work somehow
although the object was delete'd. That's why such errors are often
difficult to find (and may be OS dependent).

Jim Graham

unread,
Mar 22, 2015, 11:33:06 PM3/22/15
to fltkg...@googlegroups.com
Thanks for the help.


--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) | "Some people are like Slinkies, they serve no
spook...@gmail.com | real purpose but you still get a good laugh
< Running Mac OS X Lion > | when you kick them down the steps."
ICBM / Hurricane: | ("borrowed" from someone else's sig)
30.44406N 86. 59909W |
http://fineartamerica.com/profiles/4-james-graham.html

MacArthur, Ian (Selex ES, UK)

unread,
Mar 23, 2015, 5:15:01 AM3/23/15
to fltkg...@googlegroups.com

> Did that...got a ton of errors---the file didn't come through as plain
> text (had all of those =3D and similar. Please attach the file instead
> of putting it inline. Perhaps zip it (or use .tar.gz, etc.). That
> should keep it clean of all of that. I tried to clean it up, but it
> got turned into a mess somewhere in transit.

Sorry; I was only trying to help.

The file was posted with Apple Mail, which is *usually* OK for encoding files... Outlook tends to be worse I find.

That said, the file I posted was received here (via Outlook) perfectly, and it seems to be fine on the google groups web interface too.

Is there something unusual is the mail transit at your end that might be munging things up a bit?

Did the example code work once you got it to compile? Does it illustrate the things you were asking about?

--
Ian



Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

MacArthur, Ian (Selex ES, UK)

unread,
Mar 23, 2015, 5:15:46 AM3/23/15
to fltkg...@googlegroups.com
> PS: @Ian: needed one fix in line #18:
>
> -#include <Fl/fl_draw.H>
> +#include <FL/fl_draw.H>

Sorry; was testing on the Mac, so not as case sensitive as it might be...

Jim Graham

unread,
Mar 23, 2015, 6:47:21 AM3/23/15
to fltkg...@googlegroups.com
On Mon, Mar 23, 2015 at 09:14:57AM +0000, MacArthur, Ian (Selex ES, UK) wrote:
>
> > Did that...got a ton of errors---the file didn't come through as plain

> Sorry; I was only trying to help.

I know, and I appreciate it...didn't mean to imply otherwise.

> Is there something unusual is the mail transit at your end that might
> be munging things up a bit?

Probably just different variations of "text/plain" (different standards,
etc.---having a chemobrain blank on the names of the different ISO
standards right now).

> Did the example code work once you got it to compile? Does it
> illustrate the things you were asking about?

I didn't get that far last night...felt like I was getting my head bashed
in here, so I got the code I was working on to work, and just put it all
up. I'll try yours out today.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) | Peter da Silva: No, try "rm -rf /"
spook...@gmail.com | Dave Aronson: As your life flashes before
< Running Mac OS X Lion > | your eyes, in the unit of time known as an
ICBM / Hurricane: | ohnosecond.... (alt.sysadmin.recovery)

Jim Graham

unread,
Mar 23, 2015, 11:25:30 AM3/23/15
to fltkg...@googlegroups.com
I have one more question on this same topic.... As mentioned here, I
have a memory leak in this test program, which, if not corrected now,
will ultimately make its way into the real program, which would obviously
be very bad. But this:

Fl_PNG_Image foo = ......

and later,

foo->release();

only gets me a compile error, saying there's no member in Fl_PNG_Image
called release.

So what WOULD I release, then?

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running Mac OS X Lion >
spook...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W
http://fineartamerica.com/profiles/4-james-graham.html

In light of DHS's recommendation to defend yourself
against armed intruders with scissors, I'm giving
my deer rifle a new nickname: Scissors.

Greg Ercolano

unread,
Mar 23, 2015, 12:08:17 PM3/23/15
to fltkg...@googlegroups.com
On 03/23/15 08:25, Jim Graham wrote:
> I have one more question on this same topic.... As mentioned here, I
> have a memory leak in this test program, which, if not corrected now,
> will ultimately make its way into the real program, which would obviously
> be very bad. But this:
>
> Fl_PNG_Image foo = ......
>
> and later,
>
> foo->release();
>
> only gets me a compile error, saying there's no member in Fl_PNG_Image
> called release.
>
> So what WOULD I release, then?

If you created the instance with 'new' (e.g. 'new Fl_PNG_Image')
then you'd destroy the instance in the usual c++ fashion with 'delete'.
From the docs for the constructor (Fl_PNG_Image::Fl_PNG_Image):

"""
The constructor loads the named PNG image from the given png filename.

The destructor frees all memory and server resources that are used by
the image.
"""

So to trigger the destructor, delete the instance.

Or, if you're doing something like an image viewer, it may be better
to keep the one instance and keep loading the new images into that one
instance.

Greg Ercolano

unread,
Mar 23, 2015, 12:18:18 PM3/23/15
to fltkg...@googlegroups.com
On 03/23/15 02:14, MacArthur, Ian (Selex ES, UK) wrote:
> The file was posted with Apple Mail, which is *usually* OK for encoding files...
> Outlook tends to be worse I find.

Ya, I've noticed that about your msgs Ian.. the TNEF encoding
is what's causing the =3D stuff.

I've tuned Thunderbird to "behave" by turning off "TNEF" by
having it post in plain text, and to not wrap long lines by
setting the wrap margin to 999.

In thunderbird, if your messages default to plain text,
you can hold down SHIFT while hitting "Reply" or "Write"
and you get an html style mail editor, so that one can
switch back+forth easily. Perhaps Apple Mail/Outlook have
something similar.

Plain text does mean I have to do manual linefeeds on msgs,
but my finger muscles have long been trained to do that
automatically from a decade of using AT&T "Mail" and "elm".. ;)




Jim Graham

unread,
Mar 23, 2015, 12:18:48 PM3/23/15
to fltkg...@googlegroups.com
On Mon, Mar 23, 2015 at 09:08:10AM -0700, Greg Ercolano wrote:
> On 03/23/15 08:25, Jim Graham wrote:
>
> If you created the instance with 'new' (e.g. 'new Fl_PNG_Image')

I did.

> then you'd destroy the instance in the usual c++ fashion with 'delete'.

Ok. I thought I had that wrong, as it doesn't actually remove the image
itself (but then, I didn't redraw the box, so why ... ahh, yes, I see
where I got it wrong....). The delete was right...the lack of a redraw
is why I thought it was wrong. Got it. And yes, that's yet another
example of chemobrain in action. It's really causing me problems right
now...not normally this annoying. I'll put it very simply: cancer
sucks...even after it's been banished to a hazmat bin, cancer (and cancer
treatment) can leave behind a lot of damage...damage that doesn't go
away ... ever.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) |
spook...@gmail.com | BOFH Excuse for the day:
< Running Mac OS X Lion > |

Jim Graham

unread,
Mar 23, 2015, 12:38:16 PM3/23/15
to fltkg...@googlegroups.com
On Mon, Mar 23, 2015 at 09:08:10AM -0700, Greg Ercolano wrote:

I missed this before, so I'm responding to it now.

> Or, if you're doing something like an image viewer, it may be better
> to keep the one instance and keep loading the new images into that one
> instance.

It's an image editor, focused specifically on photography and ease of use.
I'm just putting the pieces together right now, figuring out how to do
the basic UI stuff. And yes, the idea is to have one primary window for
each image, then spawn off a preview window for image processing methods
that are adjustable (as oppsed to grayscale, etc.). Then do the actual
processing using OpenCV and a Mat copy of the image, display the changes
in the preview window, and if the user hits "OK" convert/copy the new
image back to PNG and display it in the same Fl_Window/box/win.

However, I'm told that still leaves a memory leak. I did note that,
even after doing:

delete image[fn];
box[fn]->redraw();

that the image is still there. I'm not sure if that's right or not.

Thanks,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running Mac OS X Lion >
spook...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W
http://fineartamerica.com/profiles/4-james-graham.html

Do not look into waveguide with remaining eye.

Jim Graham

unread,
Mar 23, 2015, 12:43:30 PM3/23/15
to fltkg...@googlegroups.com
On Mon, Mar 23, 2015 at 11:38:12AM -0500, Jim Graham wrote:
> On Mon, Mar 23, 2015 at 09:08:10AM -0700, Greg Ercolano wrote:

> even after doing:
>
> delete image[fn];
> box[fn]->redraw();
>
> that the image is still there. I'm not sure if that's right or not.

UPDATE: I noticed that I didn't add the win[fn]->show() after the
above. When I did so, it caused a bus error. That's a pretty clear
indication to me that the image data is no longer there. Moving on.

Thanks all,
--jim

--
THE SCORE: ME: 2 CANCER: 0
73 DE N5IAL (/4) MiSTie #49997 < Running Mac OS X Lion >
spook...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W
http://fineartamerica.com/profiles/4-james-graham.html

The UNIX Guru's View of Sex:
# unzip ; strip ; touch ; finger ; mount ; fsck ; more ; yes ; umount ; sleep

Reply all
Reply to author
Forward
0 new messages