Results 1 to 5 of 5

Thread: C++: LoadImage() Function crashing WinXP HELP!!! [HALF RESOVLED]

Threaded View

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    C++: LoadImage() Function crashing WinXP HELP!!! [HALF RESOVLED]

    My game has been working on all machines until late.
    I decided to impliment a neat title screen, looks really good. Works on my WinMe comp just fine.

    It crashing instantly upon calling my self-written LoadBMP function on a WinXp Sp2 machine. I debugged the hell out of it and I know it crash's once it hits a function which calls my LoadBmp function a few times...

    Could someone look over this and tell me why Xp would not enjoy it:
    PHP Code:
    //-----------------
    //Create Dx7 Surface from DC
    //-----------------
    LPDIRECTDRAWSURFACE7 DDSurface7::CreateSurface(LPDIRECTDRAW7 &DDcharFileNameBOOL UseSystemMemoryint TransCol)
    {
        
    HBITMAP                 hbm;
        
    BITMAP                 bm;
        
    DDSURFACEDESC2         ddsd;
        
    LPDIRECTDRAWSURFACE7 Surface;
        
    long                 WidthHeight;

        
    HDC                     hdcPicture,    hdcSurface;
        
    DDCOLORKEY             ddckColourKey;
        
    DDPIXELFORMAT         ddpf;
        
        
    RECT            rTemp;
        
    //Load up the file
        
    hbm = (HBITMAP)LoadImage(NULLFileNameIMAGE_BITMAP00LR_LOADFROMFILE|LR_CREATEDIBSECTION );
        
        
    //Size up the object
        
    GetObject(hbmsizeof(bm), &bm);
        
    Width bm.bmWidth;
        
    Height bm.bmHeight;
        
        
    ZeroMemory(&ddsd,sizeof(ddsd));
        
    ddsd.dwSize sizeof(ddsd);
        
    ddsd.dwFlags DDSD_CAPS;
        
    ddsd.dwFlags ddsd.dwFlags DDSD_WIDTH DDSD_HEIGHT;
        if (
    UseSystemMemory)
            
    ddsd.ddsCaps.dwCaps DDSCAPS_OFFSCREENPLAIN DDSCAPS_SYSTEMMEMORY;
        else
            
    ddsd.ddsCaps.dwCaps DDSCAPS_OFFSCREENPLAIN;    

        
    ddsd.dwWidth Width;
        
    ddsd.dwHeight Height;

        
    //set up our blt rect
        
    rTemp.right Width;
        
    rTemp.bottom Height;
        
        
    //Create a blank surface
        
    DD->CreateSurface(&ddsd, &SurfaceNULL);

        
    //get a new DC
        
    hdcPicture CreateCompatibleDC(NULL);

        
    //point the picture to the new DC
        
    SelectObject(hdcPicturehbm);


        
    Surface->GetDC(&hdcSurface);
        
    StretchBlt(hdcSurface00ddsd.dwWidthddsd.dwHeighthdcPicture00,
                   
    WidthHeightSRCCOPY);

        
    Surface->ReleaseDC(hdcSurface);

        
    //Sets our transparency--Black(1), Magenta(2)
        
    if (TransCol==1)
        {
            
    ddckColourKey.dwColorSpaceLowValue 0;
            
    ddckColourKey.dwColorSpaceHighValue 0;
            
    Surface->SetColorKey(DDCKEY_SRCBLT, &ddckColourKey);
        }
        else if (
    TransCol==2)
        {
            
    Surface->GetPixelFormat(&ddpf);
            
    ddckColourKey.dwColorSpaceLowValue ddpf.dwBBitMask ddpf.dwRBitMask;
            
    ddckColourKey.dwColorSpaceHighValue ddckColourKey.dwColorSpaceLowValue;
            
    Surface->SetColorKey(DDCKEY_SRCBLT, &ddckColourKey);
        }

        
    //Clean up the DC's and STDPicture objects
        
    DeleteDC(hdcPicture);
        
    DeleteObject(hbm);

        return 
    Surface;

    Last edited by Electroman; Dec 8th, 2004 at 07:36 PM. Reason: Added Language to tile.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

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