PDA

View Full Version : gdi question



Lionheart008
04-12-2009, 23:45
hi all.

does anybody knows more about UI / "GDIp" properties, commands and syntax ? manual help doesn't show any help.

for example: "Gdip_GetImagePixelFormat" ?

"Gdip_LoadImageFromFile(a(b) )" does probably exists ;)


hGpBitmap = Gdip_GetImagePixelFormat(JPGFileName, nFormat)

...
Case %PixelFormat1bppIndexed : strFormat = "1 bpp indexed"
Case %PixelFormat4bppIndexed : strFormat = "4 bpp indexed"
Case %PixelFormat8bppIndexed : strFormat = "8 bpp indexed"
Case %PixelFormat16bppGrayScale : strFormat = "16 bpp gray scale"
Case %PixelFormat16bppRGB555 : strFormat = "16 bpp RGB 555"
Case %PixelFormat16bppRGB565 : strFormat = "16 bpp RGB 565"
Case %PixelFormat16bppARGB1555 : strFormat = "16 bpp ARGB 1555"
Case %PixelFormat24bppRGB : strFormat = "24 bpp RGB"
Case %PixelFormat32bppRGB : strFormat = "32 bpp RGB"
Case %PixelFormat32bppARGB : strFormat = "32 bpp ARGB"
Case %PixelFormat32bppPARGB : strFormat = "32 bpp PARGB"
Case %PixelFormat48bppRGB : strFormat = "48 bpp RGB"
Case %PixelFormat64bppARGB : strFormat = "64 bpp ARGB"
Case %PixelFormat64bppPARGB : strFormat = "64 bpp PARGB"

End Select


try to build a new GDIp example for thinbasic.

any help about GDIp features would be nice. best regards, frank

Michael Clease
05-12-2009, 00:01
José does http://www.jose.it-berater.org/gdiplus/iframe/index.htm

Lionheart008
05-12-2009, 00:58
yes, that's ok with link and I know such stuff, but I would like to know what's already possible with current thinbasic beta issue and existing GDIp examples ?

"Gdip_GetImagePixelFormat" is still missing so far as I can check it.
also: "%PixelFormat1bppIndexed".

perhaps it's possible to realize this feature for next thinbasic release ? would be very nice to see that!

many thanks, good night, frank

Michael Clease
05-12-2009, 01:36
Frank if the information isn't included already then why not add it?


DECLARE FUNCTION GdipGetImagePixelFormat LIB "GDIPLUS.DLL" ALIAS "GdipGetImagePixelFormat" ( _
BYVAL pimage AS DWORD _ ' GpImage *image
, BYREF format AS LONG _ ' PixelFormat *format
) AS LONG ' GpStatus


%PixelFormat1bppIndexed = 196865
%PixelFormat4bppIndexed = 197634
%PixelFormat8bppIndexed = 198659
%PixelFormat16bppGrayScale = 1052676
%PixelFormat16bppRGB555 = 135173
%PixelFormat16bppRGB565 = 135174
%PixelFormat16bppARGB1555 = 397319
%PixelFormat24bppRGB = 137224
%PixelFormat32bppRGB = 139273
%PixelFormat32bppARGB = 2498570
%PixelFormat32bppPARGB = 925707
%PixelFormat48bppRGB = 1060876
%PixelFormat64bppARGB = 3424269
%PixelFormat64bppPARGB = 1851406
%PixelFormat32bppCMYK = 8207
%PixelFormatMax = 16

Lionheart008
05-12-2009, 11:36
thanks michael! :)

ok, here my first attempt! but something important is still missing in code. to be truly, I am not very familiar with including freeImage.dll or gdiplus.dll for thinbasic. Need help, but it's exiting to see when script will work and run ;)

a) gdiplus.dll I have included
b) example script for "Gdiplus Get_Export_list" properties is running fine ! (included in zip too)
c) the example works with:
"hStatus = GdipGetImagePixelFormat(JPGFileName, Counter)" so example counts Images and I noticed thinbasic knows "GdipGetImagePixelFormat" after including

perhaps you or anybody else can check what's missing ? thanks in advance.

my gdiplus test code example


'----------------------------------------------------------------------
'------- testscript for GDIplus.dll from frank brübach (aka Lionheart)
'----------------------------------------------------------------------

uses "UI", "File"

%PixelFormat1bppIndexed = 196865
%PixelFormat4bppIndexed = 197634
%PixelFormat8bppIndexed = 198659
%PixelFormat16bppGrayScale = 1052676
%PixelFormat16bppRGB555 = 135173
%PixelFormat16bppRGB565 = 135174
%PixelFormat16bppARGB1555 = 397319
%PixelFormat24bppRGB = 137224
%PixelFormat32bppRGB = 139273
%PixelFormat32bppARGB = 2498570
%PixelFormat32bppPARGB = 925707
%PixelFormat48bppRGB = 1060876
%PixelFormat64bppARGB = 3424269
%PixelFormat64bppPARGB = 1851406
%PixelFormat32bppCMYK = 8207
%PixelFormatMax = 16


Declare Function GdipGetImagePixelFormat Lib "GDIPLUS.DLL" Alias "GdipGetImagePixelFormat" ( _
ByVal pimage As DWord _ ' GpImage *image
, ByRef format As Long _ ' PixelFormat *format
) As Long ' GpStatus


If Uses("GDIP") < 0 Then
msgbox 0, "GDI+ lib not found"
stop
end if

dim wWidth as long value 425
dim wHeight as long value 425

function TBMain()

'------------------------------------------------------------------------------
' Create dialog
'------------------------------------------------------------------------------
dim hDlg as dword
Dialog NEW PIXELS, 0, "thinBasic using GDI+ Test", -1, -1, wWidth, wHeight, _
%WS_DLGFRAME OR _
%DS_CENTER OR _
%WS_CAPTION OR _
%WS_SYSMENU OR _
0 TO hDlg

'------------------------------------------------------------------------------
' Show dialog
'------------------------------------------------------------------------------
DIALOG SHOW modal hDlg, call dlgCallback

end function

callback function dlgCallback() as long
Dim ImagesDir As String = APP_SourcePath + "Images\"
Dim JPGFileName As String = APP_SourcePath + "Images\incredibles.jpg"
dim lWidth as long
dim lHeight as long
dim nFiles as long
dim sFiles() as string
dim Counter as long
dim x as long
dim y as long
dim cWidth as long
dim cHeight as long
Dim cForLine As Long
Local hStatus As Long
Local pImage As DWord
Local strFileName As String '= APP_SourcePath + "Images\incredibles.jpg"
Local nFormat As Long
Local strFormat As String '= APP_SourcePath + "Images\incredibles.jpg"

Dim hBitmap, hGpBitmap, pThumbnail As Long

select case cbMsg

case %WM_INITDIALOG
'------------------------------------------------------------------------------
' Create controls and Load images
'------------------------------------------------------------------------------
nFiles = DIR_ListArray(sFiles, ImagesDir, "*.*", %FILE_NORMAL Or %FILE_ADDPATH)

x = 5
y = 5
cForLine = 4
cWidth = (wWidth - (x * (cForLine + 2)) ) / cForLine
cHeight = cWidth

for Counter = 1 to nFiles

CONTROL ADD LABEL, cbHndl, 1000 + Counter, "", x, y, cWidth, cHeight, %SS_SUNKEN or %SS_BITMAP

'---Create an image handle
hGpBitmap = GDIP_CreateBitMapFromFile(sFiles(Counter))
'---Get image W and H
lWidth = GDIP_GetImageWidth(hGpBitmap)
lHeight = GDIP_GetImageHeight(hGpBitmap)
'---Alternative way to get width and height directly from file:
GDIp_GetImageSizeFromFile(JPGFileName, lWidth, lHeight)

pThumbnail = GDIp_GetImageThumbnail(hGpBitmap, cWidth, cHeight)

'---Convert to a hBitbam handle
hBitmap = GDIp_HBitMapFromBitmap(pThumbnail)
'---Release GDI image
GDIP_DisposeImage(hGpBitmap)
GDIP_DisposeImage(pThumbnail)

'hStatus = Gdip_LoadImageFromFile(sFiles(Counter))
'hGpBitmap = Gdip_LoadImageFromFile(sFiles(Counter))

hStatus = GdipGetImagePixelFormat(JPGFileName, Counter)
hGpBitmap = GdipGetImagePixelFormat(JPGFileName, nFormat)
hGpBitmap = GdipGetImagePixelFormat(JPGFileName, pThumbnail)

Select Case pThumbnail '-Counter
Case %PixelFormat1bppIndexed : strFormat = "1 bpp indexed"
Case %PixelFormat4bppIndexed : strFormat = "4 bpp indexed"
Case %PixelFormat8bppIndexed : strFormat = "8 bpp indexed"
Case %PixelFormat16bppGrayScale : strFormat = "16 bpp gray scale"
Case %PixelFormat16bppRGB555 : strFormat = "16 bpp RGB 555"
Case %PixelFormat16bppRGB565 : strFormat = "16 bpp RGB 565"
Case %PixelFormat16bppARGB1555 : strFormat = "16 bpp ARGB 1555"
Case %PixelFormat24bppRGB : strFormat = "24 bpp RGB"
Case %PixelFormat32bppRGB : strFormat = "32 bpp RGB"
Case %PixelFormat32bppARGB : strFormat = "32 bpp ARGB"
Case %PixelFormat32bppPARGB : strFormat = "32 bpp PARGB"
Case %PixelFormat48bppRGB : strFormat = "48 bpp RGB"
Case %PixelFormat64bppARGB : strFormat = "64 bpp ARGB"
Case %PixelFormat64bppPARGB : strFormat = "64 bpp PARGB"
Case Else : strFormat = Format$(pThumbnail)'(nFormat) '(Counter)
End Select

MsgBox 0, "The pixel format of the image is " & strFormat, %MB_ICONINFORMATION, "gdiplus_pixel test"

CONTROL SEND cbHndl, 1000 + Counter, %STM_SETIMAGE, %IMAGE_BITMAP, hBitmap

'---Release temp hBitmap
object_delete(hBitmap)
'control set resize hDlg, 1000 + Counter, 0, 1, 0, 0

x += 5 + cWidth
if mod(Counter, cForLine) = 0 then
x = 5
y += 5 + cHeight
end if

next

end select

end function



last edit: update the code example with little success ;) this version seems to run and show results with


"hGpBitmap = GdipGetImagePixelFormat(JPGFileName, pThumbnail)"

seven messages will appear for testing: for example


the pixelformat of the image is: 24552584 (24525184)

perhaps anybody can check this code too if it's running on his machine.

best regards, frank

Michael Hartlef
06-12-2009, 12:51
yes, that's ok with link and I know such stuff, but I would like to know what's already possible with current thinbasic beta issue and existing GDIp examples ?

"Gdip_GetImagePixelFormat" is still missing so far as I can check it.
also: "%PixelFormat1bppIndexed".

perhaps it's possible to realize this feature for next thinbasic release ? would be very nice to see that!

many thanks, good night, frank


Franck, open up a request topic so your wish doesn't get burried inside the topic.

ErosOlmi
07-12-2009, 19:31
Thanks Michale for the suggestion.
Forum is becoming quite big so a little of "methodology" is necessary.

Eros