Results 1 to 8 of 8

Thread: Okay I'm Stumped (on Bitmaps)

  1. #1

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    Unhappy Okay I'm Stumped (on Bitmaps)

    Hi Everyone

    I made a small program that uses GetPixel and SetPixel to
    scan through a bitmap and change colors. So far so good.
    The problem is trying to save the images.

    Well, the images save, but only the original, not the new,
    touched up versions.

    What fine point of bitmap manipulation am I missing?

    Thank You

  2. #2
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    We need a little more information to answer your question. Like, where in the memory are you manipulating the bitmap and how are you trying save it?

    That or you can just paste some of you code here and we can help possibly.
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  3. #3

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294
    Hi Again

    The program itself is real simple.

    I declared a variable as picture, used a common dialog to get
    a filename and then set the picture.

    The picture is then loaded (LoadPicture) into a picturebox (scalemode = 3 ,
    autoredraw = false). I change autoredraw to true right before
    saving. (SetPixel won't work with autoredraw set to true and
    I can't save without autoredraw = true. Life is full of irony).

    I sample the area I want to change using GetPixel, then use ShowColor to get the (Long of the) color I want to change to, then use a loop to make the changes (SetPixel).

    The picture is saved using the SavePicture function.

    I tried declaring and setting (As Picture) the current Picture1.Image before saving, but that didn't work either.

    Thank you for any light you can shed!

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'm sure you need AutoRedraw set to true when you edit the pixels for it to have effect, cos as soon as it refreshes it'll undo the changes you've made. Mind if you want to use it I'v added a class I made which handles bitmaps using offscreen DCs, which is a lot faster than using SetPixel and GetPixel. Try using the GetByteArray and SetByteArray, they use a 2D byte array. Example is with it in the download.
    Hope it helps.
    Attached Files Attached Files
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    Smile Resolved.....sort of

    Hi Everyone

    Thanks Electroman and I'll check out the module you
    posted when I get home.

    I finally got it got work. Since speed isn't an issue, I ended
    up not using SetPixelV to do the work. I experimented with
    line and pset (both work fine, but a bit pokey) and settled
    on pset.

    No matter what I tried, I couldn't create a persistent image
    using SetPixel.
    Last edited by Rocketdawg; Feb 13th, 2003 at 09:19 PM.

  6. #6
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    you have to set AutoRedraw = True....
    when the changes to the picture is done with SetPixel(V) do Picture1.Refresh
    then save with SavePicture and use the picture1.image property!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  7. #7

    Thread Starter
    Hyperactive Member Rocketdawg's Avatar
    Join Date
    Feb 2003
    Location
    Back in the doghouse
    Posts
    294

    Talking *Resolved*

    Thanks guys!

    When in doubt, start a fresh project.

    I put .refresh like cyborg suggested, and all's right with
    the world. It was a workout for this newbie!
    SetPixel is so much faster.

    Now to do those sprite masks.....But first where's that beer...

  8. #8
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    SetPixelV is a bit faster than SetPixel...SetPixel returns the previous color value of the changed pixel so thats like calling both get and setpixel...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

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