NO

Author Topic: Displaying bitmap from file  (Read 6076 times)

Offline Vortex

  • Member
  • *
  • Posts: 527
    • http://www.vortex.masmcode.com
Displaying bitmap from file
« 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.
Code it... That's all...

Anonymous

  • Guest
Displaying bitmap from file
« Reply #1 on: October 02, 2005, 05:46:02 pm »
Here is another version using my CreateBmpFromMem function.

Code: [Select]
hBitmap=CreateBmpFromMem(hwnd,pBitmap);

Offline Vortex

  • Member
  • *
  • Posts: 527
    • http://www.vortex.masmcode.com
Displaying bitmap from file
« Reply #2 on: October 02, 2005, 05:48:30 pm »
Sorry I forgot to login, the guest was me :)
Code it... That's all...

Offline Vortex

  • Member
  • *
  • Posts: 527
    • http://www.vortex.masmcode.com
Displaying bitmap from file
« Reply #3 on: November 27, 2005, 12:11:27 pm »
The DC created by CreateBmpFromMem was not released at the exit of the application - bug fixed.
Code it... That's all...

Offline Vortex

  • Member
  • *
  • Posts: 527
    • http://www.vortex.masmcode.com
Displaying bitmap from file
« Reply #4 on: February 18, 2006, 11:45:03 am »
CreateBmpFromMem function translated to POASM
Code it... That's all...

czerny

  • Guest
Re: Displaying bitmap from file
« Reply #5 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?
« Last Edit: April 25, 2014, 02:12:01 pm by czerny »

czerny

  • Guest
Re: Displaying bitmap from file
« Reply #6 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

Offline Vortex

  • Member
  • *
  • Posts: 527
    • http://www.vortex.masmcode.com
Re: Displaying bitmap from file
« Reply #7 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.
« Last Edit: April 25, 2014, 08:44:59 pm by Vortex »
Code it... That's all...

czerny

  • Guest
Re: Displaying bitmap from file
« Reply #8 on: April 25, 2014, 09:03:08 pm »
Thank you!

Offline Vortex

  • Member
  • *
  • Posts: 527
    • http://www.vortex.masmcode.com
Re: Displaying bitmap from file
« Reply #9 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));
}
Code it... That's all...