GDIPlus v1.1 usage
GDIPlus v1.1 usage
Hi,
as I'm more or less new to Freebasic I'm wondering how to use the functions from the GDIPlus v1.1 lib available on Vista+ operating systems.
For example I want to use GdipInitializePalette function but it is not defined in win\gdiplus.bi.
How can I use those functions in GDIPlus v1.1?
Thx.
as I'm more or less new to Freebasic I'm wondering how to use the functions from the GDIPlus v1.1 lib available on Vista+ operating systems.
For example I want to use GdipInitializePalette function but it is not defined in win\gdiplus.bi.
How can I use those functions in GDIPlus v1.1?
Thx.
Last edited by UEZ on May 07, 2017 16:36, edited 1 time in total.
Re: GDIPlus v1.1 usage
To my knowledge FreeBasic's Windows headers are (or at least were) based on the ones from MinGW. Often newer API functions are missing from those headers. To use those APIs you would have to declare the according function yourself and link the according library. If more than a few methods are missing you can try to translate newer gdiplus headers (e.g. from MinGW) using fbfrog or similar tools. If you do so please share your work and contribute to the FreeBasic project by submitting a patch (pull request) on GitHub or share your updated headers here on the forums. Maybe someone else has done that already? (but I can't remember any such question recently)
Re: GDIPlus v1.1 usage
Thanks for your reply St_W, I'm not an experienced FB user yet but let me try to understand how those libs working within FB.
Before I posted this question I already searched for GDI+ v1.1 but didn't find anything about it. I'm just wondering that I'm the first one who is asking about it.
GDI+ is slow but easy to use and the results are not that bad.
Before I posted this question I already searched for GDI+ v1.1 but didn't find anything about it. I'm just wondering that I'm the first one who is asking about it.
GDI+ is slow but easy to use and the results are not that bad.
Re: GDIPlus v1.1 usage
I had a quick look for the function you've mentioned and it should be already declared by the headers shipped in recent FreeBasic packages. So it shouldn't be necessary to define it yourself. It is defined in /inc/win/gdiplus-c.bi.UEZ wrote:Thanks for your reply St_W, I'm not an experienced FB user yet but let me try to understand how those libs working within FB.
Before I posted this question I already searched for GDI+ v1.1 but didn't find anything about it. I'm just wondering that I'm the first one who is asking about it.
GDI+ is slow but easy to use and the results are not that bad.
Yet here comes the strange thing: that file is only included for 64-bit builds of FreeBasic, 32-bit builds seem to use the older GDI headers which don't seem to contain the function you've mentioned.
Unfortunately I haven't used GDI+ yet - neither with FreeBasic nor any other language, so I can't tell the difference right now without having a deeper look into the headers. Maybe dkl can comment on that?
You could try to use the following instead of including win/gdiplus.bi, but I can't tell whether that would work. Yet worth a try:
Code: Select all
#inclib "gdiplus"
namespace Gdiplus
#include "win/gdiplus-c.bi"
end namespace
Re: GDIPlus v1.1 usage
I just found also that function is in gdiplus-c.bi but when I try
I get a lot of errors in winuser.bi, for example (2 lines picked):
Code: Select all
#inclib "gdiplus"
namespace Gdiplus
#include "win/gdiplus-c.bi"
end namespace
...FreeBASIC\inc\win\winuser.bi(79) error 58: Illegal specification, at parameter 1 in 'type WNDPROC as function(byval as HWND, byval as UINT, byval as WPARAM, byval as LPARAM) as LRESULT'
...\FreeBASIC\inc\win\winuser.bi(80) error 58: Illegal specification, at parameter 1 in 'type DLGPROC as function(byval as HWND, byval as UINT, byval as WPARAM, byval as LPARAM) as INT_PTR
...'
Re: GDIPlus v1.1 usage
make sure to include "windows.bi" before
But as I've already said I've no clue whether that works and if/which declarations are missing compared to the old headers used for the 32-bit compiler only. There must some difference as the old headers would have been dropped otherwise. dkl did add the new ones, so he's the person who can tell for sure.
Code: Select all
#Include "windows.bi"
#inclib "gdiplus"
namespace Gdiplus
#include "win/gdiplus-c.bi"
end Namespace
Re: GDIPlus v1.1 usage
Nope, same issue.
Then let's wait dkl's answer. :)
Then let's wait dkl's answer. :)
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: GDIPlus v1.1 usage
The following functions aren't declared in the 32 bit headers and probably not exported by the current library for FB 32 bit:
The following ones are declared in both headers, but apparently not exported by the current library for FB 64 bit (the linker fails if you try to use them):
There are differences in the definitions, e.g.:
The 32-bit headers include some defines not available in the ones for 64-bit:
There are more problems, like PathData declared both as PathData and as Any.
Code: Select all
GdipFindFirstImageItem
GdipFindNextImageItem
GdipGetImageItemData
GdipInitializePalette
GdipBitmapConvertFormat
GdipBitmapGetHistogram
GdipBitmapGetHistogramSize
Code: Select all
GdipGetMetafileHeaderFromWmf
GdipMeasureCharacterRanges
Code: Select all
ColorMap PTR for 32 bit and ColorMap_ PTR for 64 bit
GpPoint is defined as Point in 64 bit and as Point_ in 32 bit.
GpRect is defined as Rect in 64 bit and as Rect_ in 32 bit.
Code: Select all
#define GetImageDecoders(numDecoders, size, decoders) cast(GpStatus, GdipGetImageDecoders((numDecoders), (size), (decoders)))
#define GetImageDecodersSize(numDecoders, size) cast(GpStatus, GdipGetImageDecodersSize((numDecoders), (size)))
#define GetImageEncoders(numEncoders, size, encoders) cast(GpStatus, GdipGetImageEncoders((numEncoders), (size), (encoders)))
#define GetImageEncodersSize(numEncoders, size) cast(GpStatus, GdipGetImageEncodersSize((numEncoders), (size)))
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: GDIPlus v1.1 usage
Also, to get it working with both 32 and 64 bit, I have to use:
Code: Select all
#include once "windows.bi"
#ifdef __FB_64BIT__
#inclib "gdiplus"
#include once "win/gdiplus-c.bi"
#else
#include once "win/ddraw.bi"
#include once "win/gdiplus.bi"
using gdiplus
#endif
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: GDIPlus v1.1 usage
There is also a problem with the ColorMap structure, defined as ColorMap_ in gdiplus-c.bi as
to avoid conlifcts with the COLORMAP structure defined in commctrl.bi
but also defined as ColorMap (without the underscore) in GdiPlusColorMatrix.bi
I have ended using my own union:
Code: Select all
type ColorMap_
oldColor as Color
newColor as Color
end type
Code: Select all
type _COLORMAP
from as COLORREF
to as COLORREF
end type
type COLORMAP as _COLORMAP
type LPCOLORMAP as _COLORMAP ptr
Code: Select all
type ColorMap
oldColor as Color
newColor as Color
end type
Code: Select all
UNION GDIP_COLORMAP
' // For compatibility with GDI+
TYPE
oldColor AS COLORREF
newColor AS COLORREF
END TYPE
' // For compatibility with GDI
TYPE
from AS COLORREF
to AS COLORREF
END TYPE
END UNION
Re: GDIPlus v1.1 usage
I found out why the error occured from post #5. It was cause by
When I use (extract only because whole code is too long!)
I get the error
The function _GDIPlus_BitmapApplyFilter_Indexed is of course not working! It needs to be finished when I know how to use GDI+ v1.1. ^^
Seems that the GDI lib is messed up a little bit...
Code: Select all
#include Once "win\winuser.bi"
Code: Select all
#include once "windows.bi"
#ifdef __FB_64BIT__
#inclib "gdiplus"
#include once "win/gdiplus-c.bi"
#else
#include once "win/ddraw.bi"
#include once "win/gdiplus.bi"
using gdiplus
#EndIf
Using GDIPLUS
...
Type ARGB as DWORD
Type ColorPalette
Flags as UINT
Count as UINT
Entries(0 to 0) as ARGB
End Type
Type PaletteType As long
Enum
PaletteTypeCustom = 0
PaletteTypeOptimal = 1
PaletteTypeFixedBW = 2
PaletteTypeFixedHalftone8 = 3
PaletteTypeFixedHalftone27 = 4
PaletteTypeFixedHalftone64 = 5
PaletteTypeFixedHalftone125 = 6
PaletteTypeFixedHalftone216 = 7
PaletteTypeFixedHalftone252 = 8
PaletteTypeFixedHalftone256 = 9
end Enum
Type DitherType As long
Enum
DitherTypeNone = 0
DitherTypeSolid = 1
DitherTypeOrdered4x4 = 2
DitherTypeOrdered8x8 = 3
DitherTypeOrdered16x16 = 4
DitherTypeOrdered91x91 = 5
DitherTypeSpiral4x4 = 6
DitherTypeSpiral8x8 = 7
DitherTypeDualSpiral4x4 = 8
DitherTypeDualSpiral8x8 = 9
DitherTypeErrorDiffusion = 10
End Enum
Declare Function GdipInitializePalette(byval as ColorPalette ptr, byval as PaletteType, byval as INT_, byval as BOOL, byval as GpBitmap ptr) as GpStatus
...
Declare Function _GDIPlus_BitmapApplyFilter_Indexed(ByVal hImage As Any Ptr, iColors As UByte) As Any Ptr
...
Function _GDIPlus_BitmapApplyFilter_Indexed(ByVal hImage As Any Ptr, iColors As UByte) As Any Ptr Export
Dim tPalette As ColorPalette
tPalette.Flags = PaletteTypeFixedHalftone256
tPalette.Count = 256
GdipInitializePalette(@tPalette, PaletteTypeFixedHalftone256, iColors, FALSE, hImage)
End Function
Code: Select all
_GDIPlus_BitmapApplyFilter.o:fake:(.text+0xe501): undefined reference to `GdipInitializePalette'
Seems that the GDI lib is messed up a little bit...