Skip to main content
GameDev.net gamedev.net
🔒 Locked

intel jpeg lib loading problems(using ddraw)

Started by The Alchemist Jun 5, 2002 at 8:31 PM 0 replies 200+ views
Original Post
The Alchemist
The Alchemist
i realy hate post help me threads, but after 2 weeks with this problem... well im trying to load a jpg image with intel jpeg lib into a ddraw surface... most of the code was even copied from a tutorial about it. but it never loads the bitmap or blit it. i already checked the code many times and i have no clue of what may be happening well thats my load codei removed the error checking to make it smaller, but in the original i check every function and new)
    
bool EasyDDraw::LoadJPG(char *filename, DDSURFACEDESC2 ddsd, LPDIRECTDRAWSURFACE7 &surface)
{
	ijlInit(&JPGprop);
  	JPGprop.JPGFile = filename;
	
	ijlRead(&JPGprop, IJL_JFILE_READPARAMS);
	
	BYTE *buffer;
	int szbuff = JPGprop.JPGHeight * JPGprop.JPGWidth * JPGprop.JPGChannels;
	
	buffer = new BYTE [szbuff];

	JPGprop.DIBWidth    = JPGprop.JPGWidth;
	JPGprop.DIBHeight   = JPGprop.JPGHeight; //Implies a bottom-up DIB.

	JPGprop.DIBChannels = 3;
	JPGprop.DIBColor    = IJL_BGR;
	JPGprop.DIBPadBytes = IJL_DIB_PAD_BYTES(JPGprop.JPGWidth, 3);
	JPGprop.DIBBytes    = reinterpret_cast <BYTE*> (buffer);

	switch(JPGprop.JPGChannels)
	{
		case 1: JPGprop.JPGColor = IJL_G;
		break;
      
		case 3: JPGprop.JPGColor = IJL_YCBCR;
		break;
		default:
		{
			//This catches everything else, but no color twist will be

			//performed by the IJL.

			JPGprop.DIBColor = (IJL_COLOR)IJL_OTHER;
			JPGprop.JPGColor = (IJL_COLOR)IJL_OTHER;
		}
		break;
	}

	ijlRead(&JPGprop, IJL_JFILE_READWHOLEIMAGE);

	ijlFree(&JPGprop);// we dont need it anymore


	HBITMAP hbm;

	//Create the bitmap and get a handle to it

	hbm = CreateBitmap (JPGprop.JPGWidth, JPGprop.JPGHeight, 1, 16, buffer);
	
    delete buffer;// we dont need this too


    HDC                     hdcImage;
    HDC                     hdc;
    BITMAP                  bm;
    
    
    // Make sure this surface is restored.

    DDSprimary->Restore();
    
    hdcImage = CreateCompatibleDC(NULL);
     
    SelectObject(hdcImage, hbm);

    GetObject(hbm, sizeof(bm), &bm);

    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
    DDSprimary->GetSurfaceDesc(&ddsd);
    if ((error = DDSprimary->GetDC(&hdc)) == DD_OK)
    {          StretchBlt(hdc,0,0,100,100,hdcImage,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
        DDSprimary->ReleaseDC(hdc);
    }
    DeleteDC(hdcImage);
    return true;
}
    
like it was 80% copied from a working code(well i dont think taht people do tutorials with non working code ) and i dont see why it wouldnt be working well thx in advance ------------------------------- MOTHERSHIP!!! hahaha! very funny! now take me outta here!!!!! [edited by - The Alchemist on June 5, 2002 9:32:55 PM]
"Everything works out in the end, if it doesn't then it is not the end"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.