Thread: create a white image

  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,195
    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.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    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, 03:52 AM