NO

Author Topic: ImageShop32 - Missing prototype for... What is that?  (Read 7060 times)

localmotion34

  • Guest
ImageShop32 - Missing prototype for... What is that?
« on: May 25, 2007, 05:29:39 PM »
LOADGIF.C(58): warning #2027: Missing prototype for 'Header' is what i get, along with 10 other prototype errors in a C source code.

I am trying to compile the ImageShop32 source by John F., and both Pelles and LccWin32 give the EXACT same errors. 

Quote
H:\Pelles and C ex\ImageShop\LOADGIF.C(58): warning #2027: Missing prototype for 'Header'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(75): warning #2114: Local 'lp' is not referenced.
H:\Pelles and C ex\ImageShop\LOADGIF.C(193): warning #2027: Missing prototype for 'IsNewDibFormat'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(203): warning #2027: Missing prototype for 'DIBNumColours'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(231): warning #2027: Missing prototype for 'ColourTableSize'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(246): warning #2027: Missing prototype for 'CreateDIB'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(300): error #2168: Operands of = have incompatible types 'struct tagRGBQUAD *' and 'unsigned char *'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(336): warning #2027: Missing prototype for 'OutLine'.
H:\Pelles and C ex\ImageShop\LOADGIF.C(455): warning #2114: Local 'lp' is not referenced.
H:\Pelles and C ex\ImageShop\LOADGIF.C(536): error #2120: Redeclaration of 'LoadGIF' previously declared at H:\Pelles and C ex\ImageShop\loadgif.h(17): found 'void * __cdecl function' expected 'void * __stdcall function(char *)'.

Now LccWin32 did spit out OBJ files for all the C sources, in which i tried using the LoadGIF.OBJ in actually loading Gifs.  What i found was that it could load EVERY gif that i had, a task most GIF decoders i have source for MISERABLY fail at. 

However, the routine LoadGif would ONLY work when called in the MAIN code, and not nested inside a procedure call. 

            hglobal=loadGIF(LPZfilename)
            BITMAPINFO bmpinfo =hglobal
            LONG BitmapBits= bmpinfo+32+8 *16
            HDC hScreenDc = GetDC(0)
            HBITMAP newBitmap = CreateDIBitmap(hScreenDc, bmpinfo->bmiHeader, CBM_INIT,BitmapBits, bmpinfo, DIB_RGB_COLORS)
            ReleaseDC(0,hScreenDc)
            SendMessage(IDC_Static, STM_SETIMAGE,IMAGE_BITMAP,newBitmap)

I have tried using the OBJ file in a simple C program, as well as PureBasic, and they both crash when the LoadGIF is called from a procedure.  My question is:

Are the errors from the compiler causing the function to crash? Why does the compiler create the OBJ file if these appear to be critical errors. 

Finally, this is the ABSOLUTE BEST gif loading routine i have ever seen written, HANDS DOWN.  Being that my goal is to create a full featured completely FREE image library for use in all languages, i have studied many, many routines.  It has NEVER failed when called from the main code section.  And i have used GIFs created from the web, Photoshop, Corel, AVD graphics studio ect. 


Is there something i am missing here? The files LoadGIF.c and LoadGIF.h are attached.  Is there something about the whole ImageShop32 package that cant be compiled on either LCC or Pelles?
« Last Edit: May 25, 2007, 05:33:16 PM by localmotion34 »

JohnF

  • Guest
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #1 on: May 25, 2007, 06:21:53 PM »
Attached is a project that uses your PCX stuff plus I added the gif loader.

There shouldn't be a problem with the gif loader. I'll have to investigate ImageShop32.

John

localmotion34

  • Guest
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #2 on: May 25, 2007, 06:59:47 PM »
Wow, it works with your example.  You changed the LoadGIF to a HDIB from a HGLOBAL, i did notice that.  The OBJ file still crashes my program from PureBasic, and using it linked with a test app in PellesC. 

If it does not crash, the the Gif color table gets corrupted it looks like. 

Why did you create a HGLOBAL before, and not a HBITMAP? 

Additionally, if i set the compiler flags to Level 2, these errors are reported for the LoadGIF module:

Quote
H:\Temp\LoadGif.c(95): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(144): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(146): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(242): warning #2215: Conversion from 'int' to 'unsigned char'; possible loss of data.
H:\Temp\LoadGif.c(431): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(447): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(489): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(515): warning #2216: Return value from function is never used.
H:\Temp\LoadGif.c(550): warning #2215: Conversion from 'int' to 'unsigned char'; possible loss of data.
H:\Temp\LoadGif.c(571): warning #2215: Conversion from 'int' to 'unsigned char'; possible loss of data.
H:\Temp\LoadGif.c(590): warning #2215: Conversion from 'int' to 'unsigned char'; possible loss of data.
H:\Temp\LoadGif.c(596): warning #2215: Conversion from 'int' to 'unsigned char'; possible loss of data.
H:\Temp\LoadGif.c(637): warning #2216: Return value from function is never used.

I am finding all of this a little hard to understand.  Why, in your example does the GIF load perfectly, but when linking it to another example with the SAME OBJ file, does it crash?

JohnF

  • Guest
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #3 on: May 25, 2007, 08:14:11 PM »
>>Why did you create a HGLOBAL before, and not a HBITMAP? 

Most of these windows types are in fact pointers to void so it doesn't make a difference.

>> Additionally, if i set the compiler flags to Level 2, these errors are reported for the LoadGIF module:

Warning like these can be corrected - give it a go.

Edit: the warning of "Return value from function is never used" - these can't be corrected, don't know why they are reported really.

>>The OBJ file still crashes my program from PureBasic, and using it linked with a test app in PellesC.

I can't comment on this as PureBasic is out of my league.

John
« Last Edit: May 25, 2007, 09:46:14 PM by JohnF »

JohnF

  • Guest
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #4 on: May 26, 2007, 10:51:17 AM »
Concerning the colours, there is a bug in CreateDIB in DibUtils.c

Where you have, at approx line 168

  lpRgbQ = ((RGBQUAD*)hDIB + sizeof(bi));

it should be

 lpRgbQ = (RGBQUAD*)((LPBYTE)hDIB + sizeof(bi));

John


JohnF

  • Guest
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #5 on: May 26, 2007, 12:25:56 PM »
Most of the warnings can be turned off with this

#ifdef __POCC__
 #pragma warn(disable: 2118) // Parameter 'var' is not referenced
 #pragma warn(disable: 2216) // Return value from function is never used
#endif

The other warnings where the compiler complains about possible loss of data can be dealt with by using casts.

Example

  *lpBuffPtr = cc;

to

  *lpBuffPtr = (BYTE)cc;

You must be confident that the cast will not effect the outcome however. In this case cc is an int but is used to get a char from the file stream so the value will never be greater than 255.

I have sent you a private message about ImageShop32.

John

localmotion34

  • Guest
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #6 on: May 26, 2007, 05:43:05 PM »
Thank you for your help john F, very much. 

I was able to write a PCX decoder, and then encoder, because the last time i posted here, you helped get me a WORKING version of the source, which i was then able to go through step by step and understand. 

the key is always to have something you KNOW works.  Now i can write a decoder/encoder of my own, in my own style of course.  I don't like using HDIBS or HGLOBALS, instead i use CreateDIBitmap after creating a bitmapinfo structure, and decompressing the image data directly to the lpvbits buffer.  thats just me though :).  thank you again for your help. 

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: ImageShop32 - Missing prototype for... What is that?
« Reply #7 on: June 05, 2007, 09:38:32 AM »
Quote
the warning of "Return value from function is never used" - these can't be corrected, don't know why they are reported really
Most functions return something for a reason - like an error code, a buffer to free, and so on. If the return value is not used after a call, it may be a bug. If the programmer is convinced this behaviour is correct, the following works (with other compilers too) to silence the warning:

Code: [Select]
(void)myfunction();

...but the #pragma warn(disable ...) woorks too, of course.
/Pelle