This project is read-only.

Adding PRG based GDIPLUSX to your own Project

Topics: Attention VFPX Admins
Sep 3, 2007 at 12:48 PM
Im not sure, but Im guessing Im missing a point somethere ...

I used the VCX and switched to the PRG based GDIPLUS Class without problems but not sure how to setup the Project for creating the Application EXE.

Do i need to include all PRG Class files and Header into the Project?
Do I need any "Set Proc to ...."

I added all files to the Project and set the Proc to all of em and called System.prg in the startup routine ... but still getting compiler errors ...

in loadprocs.prg
SET PROC TO "..\gdiplusx_PRG\Source\system.prg" ADDI
SET PROC TO "..\gdiplusx_PRG\Source\system.drawing.prg" ADDI
SET PROC TO "..\gdiplusx_PRG\Source\system.drawing.text.prg" ADDI
SET PROC TO "..\gdiplusx_PRG\Source\system.drawing.imaging.prg" ADDI
SET PROC TO "..\gdiplusx_PRG\Source\system.drawing.drawing2d.prg" ADDI
DO ("..\gdiplusx_PRG\Source\system.prg")


in the main form there i used the GDIPLUSX:
Form d:\dev\bild_import.scx has the following errors:
Unknown GDIPCLONEIMAGE - Undefined

in the program with set all the PROCs and stuff:
Program d:\dev\loadprocs.prg has the following errors:
Program SYSTEM.DRAWING - Undefined

my own small gdiplus lib stuff functions:
Program d:\dev\gdiplus.prg has the following errors:
Unknown MYENCODERS - Undefined

FUNCTION GetEncoderInfo(mimeType AS String) AS xfcImageCodecInfo
LOCAL j
LOCAL MyEncoders AS Collection
MyEncoders = _SCREEN.System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()

FOR j = 1 TO MyEncoders.Count
IF MyEncodersj.MimeType = mimeType
RETURN MyEncodersj
ENDIF
ENDFOR
ENDFUNC


which looks really strange
Sep 3, 2007 at 4:45 PM
Hi Thomas,

It looks like a few different things are going on:

Setting up your project
  • You need to add the following PRGs to you project:
    • System.PRG
    • System.Drawing.PRG
    • System.Drawing.Drawing2D.PRG
    • System.Drawing.Imaging.PRG
    • System.Drawing.Text.PRG
    • System.IO.PRG note: this is a new file in version GDIPlusX 1.00 RC
  • You do need to issue the DO SYSTEM.PRG command
  • You do NOT neet to include the .H files in your project
  • You do NOT need to issue a SET PROCEDURE TO

Compile error: Unknown GDIPCLONEIMAGE - Undefined

Somewhere in this form you must be making a call to the API function GDIPCLONEIMAGE, outside of the GDIPlusX library. In the new GDIPlusX version we changed all of the DECLARE ... IN GDIPLUS.DLL... calls to use an AS clause. All of the functions that are declared in the library now have an alias name that start with XFC. This may have worked for you in the past because we were declaring this function for you in the Init of XFCIMAGE, but you need to manually DECLARE it now if you are goin to use GDIPlus API calls outside of the library. I recomend you stick with the library's .Image.Clone() method. But if you need to keep it this way and would like the declaration code, let me know.

Compile error: Program SYSTEM.DRAWING - Undefined

I'm not sure what is causing this. You can try removing the SET PROC TOs in your LOADPROCS.PRG and see if it goes away. If not, make send me a copy of your LOADPROCS.PRG at least any lines that reference SYSTEM.DRAWING and I will have a look.

Compile error: Unknown MYENCODERS - Undefined

This looks like the compiler is confusing MyEncoders as a function instead of a collection when referenced as MyEncoders(j). You can try adding some typical compiler tricks, like making a dummy FUNCTION MyEncoders in your main PRG or adding an EXTERNAL ARRAY MyEncoders. Or just change it to use the Item method: MyEncoders.Item(j). (in both places)


I hope this takes care of it. Let me know how you make out.

Bo Durban

Sep 3, 2007 at 7:59 PM
Thomas,


binarybo wrote:

Compile error: Unknown GDIPCLONEIMAGE - Undefined

Somewhere in this form you must be making a call to the API function GDIPCLONEIMAGE, outside of the GDIPlusX library. In the new GDIPlusX version we changed all of the DECLARE ... IN GDIPLUS.DLL... calls to use an AS clause. All of the functions that are declared in the library now have an alias name that start with XFC. This may have worked for you in the past because we were declaring this function for you in the Init of XFCIMAGE, but you need to manually DECLARE it now if you are goin to use GDIPlus API calls outside of the library. I recomend you stick with the library's .Image.Clone() method. But if you need to keep it this way and would like the declaration code, let me know.

Did you include VFPPaint in your project ?
If positive, please download the latest version from this link.
When this sample was created, there was a missing overload for xfcBitmap.Clone() function, so I had to use GdipCloneImage manually.
If that's the case, please download the latest version from here:
http://weblogs.foxite.com/files/cesarchalom/vfppaint/vfppaint.zip

This new version works nice with the latest release.
If you needed to aply some modifications in the original file, let me know and I'll tell you wjere to aply the changes needed.

HTH
Cesar
Sep 4, 2007 at 11:28 AM
Hello Bo and Cesar,

thx for the replies.

I did not use VFPPaint but I might have copied that function from there and forgot about it. Changed that one to image.clone() .. strange tho that i never had any error in dev. environment on this one, even after changing everything to the new PRG based.


the Encoder Stuff was a 1:1 copy from help_system.drawing.imaging.encoder.quality.prg, thos behavior of VFP sometimes, changed it to item().

SYSTEM.DRAWING might have had something to do with the SET PROC TO stuff coz gone after made the changes mentioned above.
Bo I guess you forgot to say that one still needs the gdiplusx.vcx to add to the PJX if one uses Visual Class like IMGCANVAS.
Sep 4, 2007 at 12:05 PM
Hi Thomas,


Bo I guess you forgot to say that one still needs the gdiplusx.vcx to add to the PJX if one uses Visual Class like IMGCANVAS.


You are right, sorry I forgot to mention that one. I sometimes forget because the VCX usually gets sucked into the project automatically. The PRGs usually require manually adding.

I'm glad to hear you have it sorted now. I'll make sure this info makes it into the final documentation.

Bo Durban
Sep 4, 2007 at 1:09 PM

TBaehr wrote:
I did not use VFPPaint but I might have copied that function from there and forgot about it. Changed that one to image.clone() .. strange tho that i never had any error in dev. environment on this one, even after changing everything to the new PRG based.


In that version i didn't add the declaration for GdipCloneImage because as I was already using the xfcBitmap class, this function was already declared there.
But in the new version that function was aliased to XFCgdipCloneImage()... That's why it stopped working.