CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63

    Question problem with Bitmaps

    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?
    Attached Files Attached Files
    Last edited by phirestalker; February 21st, 2003 at 03:28 AM.

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    i just made out the project. but it has error ,
    CaptureScreen.GetDesktopImage() ??

    could u provide that CS file too


  3. #3
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63

    sure np

    here it is
    Attached Files Attached Files

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

  5. #5
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63

    question

    so what ur saying is that I should use Object and not object for the purpose???

  6. #6
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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..



    Paresh

  7. #7
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63

    I get what u mean but...

    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

  8. #8
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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..



    Paresh

  9. #9
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63

    ok

    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

  10. #10
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63

    comment

    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!!!

  11. #11
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    LOL



    Paresh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured