"drawing" on an image...

J

johnb41

My app has an image (black/white tiff) displayed in a picturebox
(scanned text document). I need the user to be able to draw either
white or black rectangles on it. (to hide/cover up sensitive
information, like credit card numbers).

I can do this by loading the file into a graphics object, and then
using the graphics object's methods to do the drawing. The modified
file is then re-displayed on the screen. (by the way, I am using the
MouseDown and MouseUp events to calculate where and how large the
rectangle needs to be)

It works, but there is a few second delay while .NET does all the
processing. Is there a way to do the drawing (click & drag rectangle)
and get INSTANT results? It's frustrating to click and drag the
rectangle, and then wait 5 or so seconds for the rectangle to appear.

This must be possible, because even the most basic graphics
applications allow simple click/drag operations to add shapes to an
image and have INSTANT feedback.

Can anyone shed some light on this?

Thanks!
John
 
R

Robin Tucker

Hummmm, what are you doing exactly in the 5 seconds it takes? Also, what
resolution is the image? Does it need to be this resolution? Is it just for
display or are you wanting to save it out again? Why not store two images:
the high resolution version and a lower resolution version - you can blit to
the lower resolution version in real-time, so the user can see, while the
rectangle is moving. When the mouse is released and the drag has stopped,
then you blit the high resolution image according to the coordinates of the
rectangle, and possibly show progress with a thread.....
 
J

johnb41

Robin,

In the 5 seconds, i usually get the time to get a snack, and check my
email. :) At least i'm productive during these 5 seconds!

But seriously, the res of a typical image is 2550x3300. That's a
letter size scan at 300ppi. What takes so long is that .net puts this
image into a graphics object. The graphics object does the drawing.
The results get put back into an image object that gets drawn inside a
picturebox. Even the fastest pc will have some delay when this is
done.

The image MUST be re-saved with the changes. That takes processor time
also. But I don't need to "save" the image until all drawing is
complete. So the process would be: Open image and display it --> draw
1 or more rectangles on image without saving it yet --> when done, do
File | Save command.

As I have it now, to show that i have rectangles on the image, i have
to save it and then re-display it. That's probably a large chunk of
the 5 seconds.

Now that you should have a better idea of what i'm trying to
accomplish, lets discuss your solution. Do you still think that "blit"
is a good solution? If so, what's a blit?

Thanks,
John
 
J

johnb41

I just thought of an idea... can't do it yet though because i need some
help from a book that i have at home.

The book called "Beginning VB.NET" (wrox) has a section on
drawing/painting vector shapes. I referred to it the other day, but it
didn't appear to help my situation, because the image was "un"
saveable. But it gave me an idea...

When i click/drag my rectangle, I will store info in a Rectangle object
(from a Rectangle class that i create). It will hold the size and
location of the rectangle.

Then on the Paint event of the Picturebox, i could access the rectangle
object and draw the shapes on the screen. The shapes would be drawn
over an existing image. At this point, the image cannot be saved with
the overlayed rectangles.

Then when i "save" my page, i will take the same rectangle info and
permanently put it in my image. This will take a few seconds to
process.

Hope this will work! :)

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top