Click to See Complete Forum and Search --> : problem with Bitmaps


phirestalker
February 21st, 2003, 01:23 AM
I am trying to use undo in my program, so I made a class to do this (see attatched) and I put a bitmap in an instance of this class BEFORE I change the bitmap object. the function for the undo click event calls a function of the undobuf class that returns object and I cast it to bitmap and assign it to the Bitmap and then refresh the form. now, the problem is, that somehow, it is saving the changed version of the bitmap, even though I saved it before I did the change. full source for form attatched. Please help

also it will only work with 24bit bitmaps, how do I change how I use the setpixel, so that it will work with all bitmaps?

pareshgh
February 21st, 2003, 12:55 PM
i just made out the project. but it has error ,
CaptureScreen.GetDesktopImage() ??

could u provide that CS file too

:D

phirestalker
February 21st, 2003, 02:13 PM
here it is

pareshgh
February 21st, 2003, 02:47 PM
yeah ! I checked your code. it seems that you are doing undo very incorrectly...
its wrong.

public object Pop()
{
object b = new object();

if(count < (size - 1))
{
b = bit.GetValue(count - 1);
}
else
{
b = bit.GetValue(count);
}
count--;
if(count == 0)
{
OnEmpty(EventArgs.Empty);
}
return b;
}

this would return a pure object and that's it. you need to implement another mechanism to get the bitmap and not the object. its not even stream but a pure object. how can u convert to a bitmap from a pure object !! no connection !!

Paresh

phirestalker
February 21st, 2003, 02:50 PM
so what ur saying is that I should use Object and not object for the purpose???

pareshgh
February 21st, 2003, 02:53 PM
no the purpose for object is converting one object from another objects of compatible types and compatible classes. its whole story about OOP.
but for timebeing you can't cast like this.
it doesn't have bitmap data.

realize that b is just a object and bitmap is more even huge in that. how can it accomodate that space anyway..

:D

Paresh

phirestalker
February 21st, 2003, 03:08 PM
I ran accross a class called Stack, in System.Collections and I was gonna use that for the undo, but it didn't have an event for empty. Anyway, this Stack class returns object, so how does it work with any kind of data??? like in an example it shows it being used for text, and another used for pictures. If their class can do it, what am I doing wrong, I want to be able to use this class in any program I make without modifying it. Thank u

pareshgh
February 21st, 2003, 03:13 PM
u can use stack and push an objects. that's the best idea. but u should butmaps instead of storing objects.

like
Bitmap b....
object o = b;

and then while poping

Bitmap b1 = (Bitmap) o;

this should work. since both ways u are storing objects as bitmaps anyways..

:eek:

Paresh

phirestalker
February 21st, 2003, 04:51 PM
I guess I'll just have to specialize it that way. Only the built in functions have the luxury of dealing with any kind of data :(

oh BTW the SetPixel method of the Bitmap class, it will only work on 24bit bitmaps. I have tried different methods and can't get it to work with other types. if it doesn't work with anything but 24bit by design and there is no way to get around it, how would I go about converting bitmaps into 24 bit before working on them?

thanks

phirestalker
February 21st, 2003, 06:17 PM
and besides give me a break anyway, I just started c# 2 weeks ago :P lol, I'll tell ya the help files are a better way to learn than any tutorial!!! :)

pareshgh
February 23rd, 2003, 08:53 PM
LOL

:D

Paresh