create a white image

This is a discussion on create a white image within the C++ Programming forums, part of the General Programming Boards category; hi all, i want a white image file with very large pixel, say about 40000 X 40000, since i cannot ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    74

    create a white image

    hi all,

    i want a white image file with very large pixel, say about 40000 X 40000, since i cannot find the same size of image to turn it into white, so i need to create myself. but i 'm new in mfc graphics, does anybody knwo how to create it? what is the procedure or any sample code? thanks!

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    create a raw bitmap image, you don't need mfc, just use plain old C to write a file header and set the data field to all 0xFF.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by mr_empty View Post
    hi all,

    i want a white image file with very large pixel, say about 40000 X 40000, since i cannot find the same size of image to turn it into white, so i need to create myself. but i 'm new in mfc graphics, does anybody knwo how to create it? what is the procedure or any sample code? thanks!
    In MFC something like;

    Code:
    //needs error checking
    
    //create an image object
    CImage  Image;
    Image.Create(40000,40000,32,0);//change depth and flags as needed
    
    //get the DC to draw to
    CDC *pDC=CDC::FromHandle(Image.GetDC());
    //fill with white
    pDC->FillSolidRect(0,0,40000,40000,RGB(255,255,255));
    
    //save image
    CString sPath="C:\\SomeFolder\\WhiteImage.bmp";
    Image.Save(sPath,GUID_NULL);
    
    //clean up
    Image.ReleaseDC(pDC->Detach());

    It is easier if you don't need to save the image. Use GetDC(), CreateCompatibleBitmap(), FillRect() and ReleaseDC().
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating Image through C
    By dssr in forum C Programming
    Replies: 5
    Last Post: 09-24-2009, 04:57 PM
  2. .jp2 image file to .bmp image file using C language
    By prabs005 in forum C Programming
    Replies: 14
    Last Post: 07-07-2009, 04:02 PM
  3. Replies: 1
    Last Post: 05-27-2009, 12:46 PM
  4. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  5. Replies: 6
    Last Post: 03-03-2005, 02:52 AM

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