How to store pixels in memory created with Setpixel(...)

This is a discussion on How to store pixels in memory created with Setpixel(...) within the Windows Programming forums, part of the Platform Specific Boards category; Hello. I have now made myself a sample program from a book that uses document/view, and I seen now how ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    12

    How to store pixels in memory created with Setpixel(...)

    Hello.

    I have now made myself a sample program from a book that uses document/view, and I seen now how scrolling the window works.

    My problem is the following. I am creating a picture from a binary file by setting one pixel at a time using setpixel(x,y,RGB_colour).

    In this way the function I'm using is making 6000 lines of pixels on the screen. My screen can only display 1200 lines at a time, so I have to be able to scroll downwards for 4800 lines of pixels.

    Now, I'm doing all of this in one function, so there is nothing in the ondraw messagehandler. So when I click the mouse on the screen the picture just go away.

    Is this because I hav'nt written any code in ondraw?? Do I put my 6000 lines of pixels into memory and use a command like showpixels in ondraw?? (I know there is'nt a command called showpixel in MFC, but what could I use?)

    Hope you understand what I'm trying to do her?

    Kristian

  2. #2
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    Probably understand much more if you post some code.

    Also, I believe SetPixel() is a very inefficient method of drawing. It's ok for small images but 6000 thousand lines worth of pixels.......there must be other, more efficient ways you could do this?

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I don't use MFC, but if I had a task like that, I would write the pixels to a back buffer and blit the required part to the screen when a paint or scroll message came in.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 05-07-2009, 02:31 AM
  2. tools for finding memory leaks
    By stanlvw in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2009, 12:41 PM
  3. Memory Leak Help
    By (TNT) in forum Windows Programming
    Replies: 3
    Last Post: 06-19-2006, 12:22 PM
  4. Linked Lists
    By bigblack in forum C++ Programming
    Replies: 7
    Last Post: 02-05-2002, 05:21 PM
  5. How do i store a file in memory?
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 01-30-2002, 07:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21