Untouched Image, or not?

Blitz3D Forums/Blitz3D Programming/Untouched Image, or not?

Mr.Waterlily(Posted 2007) [#1]
I need a way to check if an Image has been drawn to, or not, since itīs creation(with CreateImage).
The obvious would be to try using a variable that sets as soon as something is drawn to the image. And I have tried that, but it would mean that I need to change so much of my code that I would prefer another way.
I thought of simply just checking each pixel and compare it to the original color, but maybe thereīs an even better way?


LAB[au](Posted 2007) [#2]
You could do that but it will not be a fast check (checking each pixel). You could check only the topleft pixel and have your "drawing" functions always writing to it.


Mr.Waterlily(Posted 2007) [#3]
Interesting idea, I will certainly consider it!
It probably wonīt work though for this projekt I think, since the image is completely visible.
Any other ideas?


LAB[au](Posted 2007) [#4]
How about creating the image slightly bigger than the "visible area" (or what is drawn at the screen), then have your drawing functions writting in this non visible area.


b32(Posted 2007) [#5]
Maybe you could test if the buffer is used? You could then wrap the ImageBuffer() function somewhat like this:
Function wrapped_ImageBuffer(image)
   image_used = true
   return ImageBuffer(image)
End function



Mr.Waterlily(Posted 2007) [#6]
I think itīs "to late" for me to convert the whole program to have the viewports slightly larger, since I have so many routines that behave due to the size if the image.

Test if the buffer is used? Hmmmm.....
Can you explain a bit more on how you think?
I donīt think I quite follow...


b32(Posted 2007) [#7]
Actually, it depends on what you are doing to change the image. Are you using WritePixel, GrabImage, CopyRect or SetBuffer ?
The main idea is to wrap the function that you are using to write to the images with another function, that stores the images that are passed to it, to determine what images were modified.


Mr.Waterlily(Posted 2007) [#8]
Iīll see if I can wrap my actual drawing functions to set the flag when used.
The problem for me is that I use several images/buffers to draw to and itīs only one I need to check this for.
And the drawing functions can also draw "outside" the image since it can be limited with viewports. And when they draw outside, nothing changes to the image, so to do this I need to check for several coordinates which can be a bit tricky with some commands like Oval, or some custom functions that draw thicker circles.


cyberyoyo(Posted 2007) [#9]
The solution is to use a variable, any other option would be actually more problems.
The time you spent on this thread you could have probably finished it by now.