| |
|
|
Marcus Mayer | Hello on all sides!
I had there time ne question: is it possible, with on-board resources (speak only with GDIPlus o.ä.) PNGs with alpha channel in the Client-area the XProfan-Fensters to drawing, without The ProSpeed.dll To use? (under Win7)
have its Time with Profan 6 to program began and was too To Version 7.5 right busy thereby. though have I then a right long interval made and some Neuerungen bleary. Since I programmiertechnisch well quite eingerostet be, I will from so some story How z.B whom Layered windows not integrally schlau. |
|
|
| |
|
|
|
| Hello Marcus,
Andreas Miethe has "LayeredWindow with Alphakanal" [...] provided -
I have the unlieb bad verwürgt - but it draw PNGs: CompileMarkSeparationGemerkt/Separiert von http://xprofan.com/t/?7898 (Andreas Miethe)
###############################
Layered-Window mit PNG
und GDIPlus
###############################
If Val($winver) < 5
Messagebox("Die Windows-Version wird nicht unterstützt","Sorry",0)
End
Endif
###############################
Imports
###############################
Var GdiPlus& = ImportDll("GDIPlus.dll","")
###############################
###############################
Header-Dateien
$H windows.ph
$H Messages.ph
###############################
###############################
Strukturen
###############################
Struct GdiplusStartupInput = GdiplusVersion&,DebugEventCallback&,SuppressBackgroundThread&,SuppressExternalCodecs&
Struct Size = cx&,cy&
Struct Point = x&,y&
Struct Blendfunction = a#(4)
###############################
Var WW& = 280 Bildbreite
Var WH& = 280 Bildhöhe
###############################
cls
~SetClassLong(%hwnd,~GCL_STYLE,(~GetClassLong(%hwnd,~GCL_STYLE)- ~CS_HREDRAW - ~CS_VREDRAW))
SetStyle %Hwnd,1, GetStyle(%hwnd,1) | $80000 erweiterten Window-Stil setzen
Var GdiplusToken& = InitGDIPlus() GDIPlus initialisieren
Var IObject& = GdipLoadImage("BackPic.png") PNG mit Alphakanal laden
Var bm& = ~CreateBitmap(ww&,wh&,1,32,0) 32-Bit Bitmap anlegen
Var DC& = ~CreateCompatibleDC(0) DC-anlegen
~SelectObject(DC&,bm&) Bitmap ins DC
Var Graphics& = 0
GdipCreateFromHdc(%hDC,Addr(Graphics&)) Zeichnungs-Object anlegen
GdipSetSmoothingMode(Graphics&,2) weicher zeichnen
GdipDrawImageRectI(Graphics&,IObject&,0,0,ww&,wh&) Bild zeichnen
GdipDrawImageRectI(Graphics&,IObject&,50,50,ww&,wh&) Bild zeichnen
GdipDeleteGraphics(Graphics&) Zeichnugs-Object freigeben
GdipDisposeImage(IObject&) Bitmap feigeben
ExitGDIPlus(gdiplusToken&) GDIPlus beenden
waitinput
end
Parameter für UpdateLayeredWindow vorbereiten
Var Size# = New(Size)
Var Point# = New(Point)
Var Blendmode# = New(Blendfunction)
Clear Blendmode#,Point#,Size#
Size#.cx& = ww&
Size#.cy& = wh&
Byte Blendmode#,2 = 255
Byte Blendmode#,3 = 1
External("User32.dll","UpdateLayeredWindow",%hwnd, 0, 0, Size#,DC&,Point#,0,Blendmode#, 0)
UpdateLayeredWindow() übernimmt das Zeichnen/Neuzeichen des Fensters !
Die benötigten Daten zum Zeichnen holt sich die Funktion direkt vom DC !
Das geht extrem schnell, da Windows keinen weiteren Speicher reservieren muss.
Hautpschleife
#############
Var Ende& = 0
Whilenot Ende&
Waitinput
If %MousePressed = 1
Sendmessage(%hwnd,$0112,$0F012,0)
ElseIf %MousePressed = 2
OnEnd()
Endif
EndWhile
Ende-Procedur
###############################
Proc OnEnd
Dispose Size#,Point#,Blendmode#
~DeleteDC(DC&)
~DeleteObject(bm&)
Ende& = 1
EndProc
###############################
###############################
GDIPLUS
###############################
Proc InitGDIPlus
Declare gdiplusToken&
Var gdpsi# = New(GdiplusStartupInput)
gdpsi#.GdiplusVersion& = 1
gdpsi#.DebugEventCallback& = 0
gdpsi#.SuppressBackgroundThread& = 0
gdpsi#.SuppressExternalCodecs& = 0
GdiplusStartup(ADDR(gdiplusToken&),gdpsi#,0)
Dispose gdpsi#
Return gdiplusToken&
EndProc
Proc ExitGDIPlus
Parameters gdiplusToken&
GdiplusShutdown(gdiplusToken&)
FreeDLL GDIPlus&
Endproc
Proc S2WSString to WideString
Parameters S$
Declare w$
w$ = Space$((Len(s$)*2)+1)
~MultiByteToWideChar(~CP_ACP, 0, ADDR(s$), -1, ADDR(w$), Len(w$)+1)
Return w$
EndProc
Proc GDIPLoadImage
Parameters Image$
Declare result&,FileW$,Bitmap&
result& = 0
FileW$ = S2WS(Image$)
GdipCreateBitmapFromFile(ADDR(FileW$),ADDR(Bitmap&))
if Bitmap&
result& = Bitmap&
Endif
return result&
ENDPROC
###############################
Please from it a "brauchbaren" code make, had I likewise gladly.
row CompileMarkSeparation certainly spending-DC.
(PNG-Image Please from Andreas seinem pkg loading.) |
|
|
| |
|
|
|
| Etwas saubereres Beispiel:
Download
KompilierenMarkierenSeparieren'Gemerkt/Separiert von https://xprofan.com/t/?7898 (Andreas Miethe)
'
'###############################
' Layered-Window mit PNG
' und GDIPlus
'###############################
If Val($winver) < 5
Messagebox("Die Windows-Version wird nicht unterstützt","Sorry",0)
End
Endif
'###############################
'Imports
'###############################
Var GdiPlus& = ImportDll("GDIPlus.dll","")
'###############################
'###############################
'Header-Dateien
$H windows.ph
$H Messages.ph
'###############################
'###############################
'Strukturen
'###############################
Struct GdiplusStartupInput = GdiplusVersion&,DebugEventCallback&,SuppressBackgroundThread&,SuppressExternalCodecs&
Struct Size = cx&,cy&
Struct Point = x&,y&
Struct Blendfunction = a#(4)
'###############################
Var WW& = 280' Bildbreite
Var WH& = 280' Bildhöhe
'###############################
cls
Var GdiplusToken& = InitGDIPlus()' GDIPlus initialisieren
Var IObject& = GdipLoadImage("BackPic.png")' PNG mit Alphakanal laden
Var bm& = ~CreateBitmap(ww&,wh&,1,32,0)' 32-Bit Bitmap anlegen
Var DC& = ~CreateCompatibleDC(0)' DC-anlegen
~SelectObject(DC&,bm&)' Bitmap ins DC
Var Graphics& = 0
GdipCreateFromHdc(%hDC2,Addr(Graphics&))' Zeichnungs-Object anlegen
GdipSetSmoothingMode(Graphics&,2)' weicher zeichnen
whileLoop 50
GdipDrawImageRectI(Graphics&,IObject&,rnd(width(%hWnd)-ww&),rnd(height(%hWnd)-wh&),ww&,wh&)' Bild zeichnen
wend
repaint 1
GdipDeleteGraphics(Graphics&)' Zeichnugs-Object freigeben
GdipDisposeImage(IObject&)' Bitmap feigeben
ExitGDIPlus(gdiplusToken&)' GDIPlus beenden
waitinput
OnEnd()
end
'Ende-Procedur
'###############################
Proc OnEnd
~DeleteDC(DC&)
~DeleteObject(bm&)
EndProc
'###############################
'###############################
'GDIPLUS
'###############################
Proc InitGDIPlus
Declare gdiplusToken&
Var gdpsi# = New(GdiplusStartupInput)
gdpsi#.GdiplusVersion& = 1
gdpsi#.DebugEventCallback& = 0
gdpsi#.SuppressBackgroundThread& = 0
gdpsi#.SuppressExternalCodecs& = 0
GdiplusStartup(ADDR(gdiplusToken&),gdpsi#,0)
Dispose gdpsi#
Return gdiplusToken&
EndProc
Proc ExitGDIPlus
Parameters gdiplusToken&
GdiplusShutdown(gdiplusToken&)
FreeDLL GDIPlus&
Endproc
Proc S2WS'String to WideString
Parameters S$
Declare w$
w$ = Space$((Len(s$)*2)+1)
~MultiByteToWideChar(~CP_ACP, 0, ADDR(s$), -1, ADDR(w$), Len(w$)+1)
Return w$
EndProc
Proc GDIPLoadImage
Parameters Image$
Declare result&,FileW$,Bitmap&
result& = 0
FileW$ = S2WS(Image$)
GdipCreateBitmapFromFile(ADDR(FileW$),ADDR(Bitmap&))
if Bitmap&
result& = Bitmap&
Endif
return result&
EndProc
'###############################
|
|
|
| |
|
|
|
Marcus Mayer | Erstmal many many Thanks for speedy response! Kanns hardly expect, the whole auszuprobieren. |
|
|
| |
|
|
|
Marcus Mayer | means over again many Thanks for crazy response. I do not understand though in the detail, How the whole functions, could me but a Include-File basteln, circa with a lovely Einzeiler discretionary PNGs to drawing. very I wished ought to the whole in later Projekten application find, name I The edlen code-contributor naturally |
|
|
| |
|
|
|
|
means over again many Thanks for crazy response. I do not understand though in the detail, How the whole functions, could me but a Include-File basteln, circa with a lovely Einzeiler discretionary PNGs to drawing. very I wished
gladly happen!
ought to the whole in later Projekten application find, name I The edlen code-contributor naturally
Poste still The thereby herausgekommene Include with whom Includes [...] - having against any something of it - had I z.B. too gladly. |
|
|
| |
|
|
|
| Marcus Mayer, Beitrag=57235, Zeitpunkt=27.05.2010
Mach I still saponaceous.^^ before I The Include however official available place, would I here you again in advance to Durchsicht post. I can also yet gladly a small example-code add, if desired. becomes but well not necessary his
Ah, i see what you mean - however too these Besprechung to coming into being the Include ought to vlt. rather in the Include-Thread for Disposal stand - naja for is it Yes the Include-Thread. ^^ its too legitim z.B. Includes- or programs or ... -Threads as Ideengrundlage only with of/ one Skizze To post, circa therein first to develop or others on the development to share.
Info: You can anytime your Topics/ Posts/ Files/ Includes/ programs... etc. anytime Edit and delete - to simply the Beitragsdatum clicking.
we could if you want The Include too detach to a new Thread with whom Includes. |
|
|
| |
|
|
|
Marcus Mayer | Okay, then make wirs so be here in the community still not all too long and know The Gepflogenheiten therefore not yet so.
then Better get going well too Time, The Thread here as Done To taggen, correctly.? |
|
|
| |
|
|
|
| very, I mach the time to. ^^
Nachtrag: now I had your Include herausgeteilt - synchron had You these too with whom Includes laid out. have whom herausgeteilten Thread simply again removes. ^^ |
|
|
| |
|
|