Pelles C forum

C language => Tips & tricks => Topic started by: Vortex on November 29, 2004, 08:24:12 PM

Title: Displaying bitmap from file
Post by: Vortex on November 29, 2004, 08:24:12 PM
Hi friends,

Here is a demo program displaying a bitmap from file without using the conventional Win32 resource system.
Title: Displaying bitmap from file
Post by: Anonymous on October 02, 2005, 05:46:02 PM
Here is another version using my CreateBmpFromMem function.

Code: [Select]
hBitmap=CreateBmpFromMem(hwnd,pBitmap);
Title: Displaying bitmap from file
Post by: Vortex on October 02, 2005, 05:48:30 PM
Sorry I forgot to login, the guest was me :)
Title: Displaying bitmap from file
Post by: Vortex on November 27, 2005, 12:11:27 PM
The DC created by CreateBmpFromMem was not released at the exit of the application - bug fixed.
Title: Displaying bitmap from file
Post by: Vortex on February 18, 2006, 11:45:03 AM
CreateBmpFromMem function translated to POASM
Title: Re: Displaying bitmap from file
Post by: czerny on April 25, 2014, 02:02:42 PM
Hallo Vortex!

I would like to learn, howto include asm files in an Pelles C projekt. So I played a little with your example. I have removed the depandencies from other crts.

I get the following error while building the project:

Building Bmpfile.obj.
Building BmpMem.obj.
*** Error:  -W0 -Cu  -Fo"E:\c\src\bmp\output\BmpMem.obj" "E:\c\src\bmp\BmpMem.asm"
*** Error: file not found. 
Done.

Shouldn't there be 'poasm'  in front of the command line?
Is the ide able at all to compile the asm file automatically?

czerny

Edit: I found it!

The make macro AS was empty and the ASFLAGS -W0 and -Cu were wrong.
May be you have used an other assembler? What should the above switches do?
Title: Re: Displaying bitmap from file
Post by: czerny on April 25, 2014, 02:26:42 PM
Another question!

the file 'BmpMem.obj' is created in the output directory, like other obj-files.
But ...

Building Bmpfromfile.exe.
POLINK: fatal error: File not found: 'BmpMem.obj'.
*** Error code: 1 ***
Done.

If  I copy the file in the project root directory, I get ...

Building Bmpfromfile.exe.
POLINK: error: Symbol '_CreateBmpFromMem@12' is multiply defined: 'BmpMem.obj' and 'E:\c\src\bmp\output\BmpMem.obj'.
*** Error code: 1 ***
Done.

Thats funny! In the first step it couldn't find it at all. Now it finds it twice!

Is it possible to solve this puzzle without expanding the lib path?

czerny
Title: Re: Displaying bitmap from file
Post by: Vortex on April 25, 2014, 08:42:24 PM
Hi czerny,

Here is the project updated with Pelles C V7. Removing the assembly module from the library and object files line solved the problem. Now, the assembly code is a member of the project files. It's assembled with Poasm. The original example from 2006 has probably an outdated .ppj file.
Title: Re: Displaying bitmap from file
Post by: czerny on April 25, 2014, 09:03:08 PM
Thank you!
Title: Re: Displaying bitmap from file
Post by: Vortex on April 26, 2014, 10:28:09 AM
Hi czerny,

Rewriting CreateBmpFromMem in C :

Code: [Select]
HBITMAP __stdcall CreateBmpFromMem( HWND hwind , LPVOID pImg , HDC* tempDC)
{
HDC hdc;

char *bmpheader = (char *)pImg + sizeof(BITMAPFILEHEADER);


LPVOID lpbInit = (LPVOID)((int)pImg + ((LPBITMAPFILEHEADER)pImg)->bfOffBits) ;

hdc=GetDC(hwind);
*tempDC=hdc;

return (CreateDIBitmap(hdc,
(LPBITMAPINFOHEADER)bmpheader,
CBM_INIT,lpbInit,
(LPBITMAPINFO)bmpheader,
DIB_RGB_COLORS));
}