English
Forum

PNGs with alpha channel without ProSpeed.dll

 

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.
 
05/08/10  
 



Hello Marcus,

Andreas Miethe has "LayeredWindow with Alphakanal"  [...]  provided -

I have the unlieb bad verwürgt - but it draw PNGs:
CompileMarkSeparation
Gemerkt/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.)
 
05/09/10  
 



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

'###############################

1.074 kB
Hochgeladen:05/09/10
Downloadcounter240
Download
15 kB
Hochgeladen:05/09/10
Downloadcounter255
Download
57 kB
Kurzbeschreibung: von http://xprofan.com/t/?7898 (Andreas Miethe)
Hochgeladen:05/09/10
Downloadcounter229
Download
 
05/09/10  
 




Marcus
Mayer
Erstmal many many Thanks for speedy response!
Kanns hardly expect, the whole auszuprobieren.
 
05/12/10  
 




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
 
05/23/10  
 




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.
 
05/23/10  
 



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.
 
05/27/10  
 




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.?
 
05/27/10  
 



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. ^^
 
05/28/10  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

10.599 Views

Untitledvor 0 min.
Sven Bader11/22/21
Georg Teles08/20/21
RudiB.08/16/21
Normann Strübli09/14/20
More...

Themeninformationen

this Topic has 2 subscriber:

iF (5x)
Marcus Mayer (4x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie