Foro | | | | Thomas Freier | Irgendwie habe ich ein Problem. Ich dachte mit DrawPic H, X, Y; N1[, N2] und das Handle einer Bitmap kann z.B. das Ergebnis der Funktion @Create("hPic",...) oder ... potuto ich auch *.png verwenden oder liege ich mit folgendem Skript fasch? KompilierenMarkierenSeparierenDeclare bereich#,x&,y&,z&,p&,text$
Def GetSysColor(1) !"USER32","GetSysColor"
SetTrueColor 1
Proc CatchBmp
Parameters MemPointer&
Declare hDC&, BITMAPFILEHEADER#, BMPInfo&, init&, hImage&
hDC& = External("user32.dll", "GetDC", External("user32.dll", "GetDesktopWindow"))
Dim BITMAPFILEHEADER#, 14
BITMAPFILEHEADER# = MemPointer&
BMPInfo& = MemPointer& + 14
init& = MemPointer& + Long(BITMAPFILEHEADER#, 10)
hImage& = External("gdi32.dll", "CreateDIBitmap", hDC&, BMPInfo&, 4, init&, BMPInfo&, 0)
External("user32.dll", "ReleaseDC", External("user32.dll", "GetDesktopWindow"), hDC&)
Dispose BITMAPFILEHEADER#
Return hImage&
EndProc
*** Hier stehen die Bilddaten aus bmp direkt im Quellcode.
Erstellt am 21. Februar 2010 mit dem XProfan Datengenerator, (C) Frank Abbing
Datei: E:profanXDatengeneratoricon4.bmp (originale Dateigröße: 1334 Bytes)
Declare mem#
Dim mem#,1336
Clear mem#
Long mem#,0=87444802
Long mem#,8=70647808,2621440,1048576,1048576,65536,8,16777216
Long mem#,44=16777216
Long mem#,52=-617349120,-617283329,-634060545,-600571649,-600637185,1545142527,-600506244,-583728897,1545142527,-583794563,-96861953,-432537345,-517537537,-264765185,-567017217,-130416385,-735444737,2082734335,2099445904
Long mem#,128=1533280402,-449380262,1478230271,-231210905,-971570945,-904593153,-971636481,-550174465,-550108929,-298319617,-566886145,1853423871,-382271382,1533083903,-585695137,-1190199041,-482934535,890568959,-499711937
Long mem#,204=1782513919,1617625218,-516489122,-197525249,-533200641,1566376191,1882980448,1899692172,1966538895,-600768363,1364721919,-1474887602,-1005256476,-415891202,-130481921,-853278465,-551288577,1092223231,-1558773674
Long mem#,280=-1491861280,-2025979675,-534183766,1396703487,1545076828,1819672702,-399048596,-500891393,1578762495,1075314814,1262420043,1634140244,-466288542,1920925951,-1474887569,705954021,-921370575,-650837761,-667614977
Long mem#,356=-482868993,1562050815,-348716931,-718601985,-365494017,-466222849,-214368001,-1875246849,-466091852,1664811263,-382205834,1948385535,-365363065,-786038529,-583663361,-483000065,-1305673473,-706477877,-1407647534
Long mem#,432=-499777302,-516554497,-925433601,1904017605,-113639311,-874970881,1259995335,739508310,1276772402,-466812838,2084831487,-499646315,101449983,151912454,403701768,1882849305,-398983030,-1858469633,-1642659658
Long mem#,508=-331874087,-672792321,-247922476,1545404671,-2092826502,-1592262494,1713373404,1732378757,1648754813,524404,1110638592,-449314740,1545208063,-432603012,-1758199553,1431699648,-752353191,-921435905,1429471487
Long mem#,584=-667811741,1482555647,1914765401,-1171390333,470941907,-550043617,-954859265,-453836545,225
Long mem#,1076=1012727808,84229453,134744069,1967226373,579105603,50594863,151852558,67567872,1752726585,235471643,856786757,704708870,405485445,50331744,1863673183,1783300609,-2138274210,198459,1351113842,1331298818,-2121495506
Long mem#,1160=67132233,879174755,1196163402,-1936946128,102370416,172115978,756030722,-1936946036,122782496,258370857,321999878,-1936946036,588010380,227109966,-1943240155,-1936946036,529220748,476806015,-1943586805,-1936946036
Long mem#,1240=1077578892,1477597053,-1936972199,-1936946036,389975180,343167551,-1936974217,-1936946036,1988922508,891849270,-1936946055,-1936946036,1653378188,1896568370,-1936946106,-1936946036,-1936946036,2048467305,-1936946036
Long mem#,1316=-1936946036,-1936946036,1683320417,-1936946036,35980
Declare hBild&
hBild& = CatchBmp(mem#)
Dispose mem#
Erstellt am 21. Februar 2010 mit dem XProfan Datengenerator, (C) Frank Abbing
Datei: E:profanXDatengeneratoricon4.png (originale Dateigröße: 1049 Bytes)
Dim mem#,1052
Clear mem#
Long mem#,0=1196314761,169478669,218103808,1380206665,268435456,268435456,776,254617600,50331731,1414287360,886832965,-13247489,-587254310,870121268,-15115140,-570477092,425491765,-13312513,-419480838,669122360,-13045505
Long mem#,84=-117492514,718602042,-1843102576,1532633981,937820004,-14919577,-956352270,365625111,-15284481,-536922657,955186998,1781980927,-369133202,1633378103,-115876353,-469823559,355811127,-2110266625,1616789354,937557867
Long mem#,164=-12913409,1566587104,1014008925,-1791266417,-587253899,1481723441,-32003868,-402713148,972619574,-14365185,1096164575,396615706,-1441486875,-520143225,1079204905,1813535870,-385911188,635633463,1260019326,1263802432
Long mem#,244=1734435391,1865803007,-1461354638,338309399,-15349249,-654363175,954466101,-14983811,-704694293,938147627,-13179649,-1867236877,954531642,-12885130,1955018985,971702050,-14233089,-469813539,766692150,-354101806
Long mem#,324=-486598228,920780598,1909967045,-100696719,-640956614,840584022,1280971820,769982234,-12288875,101071074,235472908,-1978656743,-385926544,982627896,-15229223,-673957652,972160998,-1575134086,-1579400573,543589656
Long mem#,404=1950508925,18018,859982856,2084103679,-419489188,882360375,-11119271,-906024749,878011156,1496504575,1921211992,783995681,-15590369,-939575329,-203103978
Long mem#,808=1181556736,215,1094994388,1671198804,-998047256,135581884,1698824587,559303210,-2061949941,565843825,1972999177,576100457,-305861628,-901494141,1443029221,1122088206,812290321,-110192895,426568442,-1468724370
Long mem#,888=-1299238848,-1356378529,1141805930,-1875271360,-1925762211,1355034015,-1068487656,-439958237,616940769,302751787,1720513640,1230391648,-194842313,167786353,867391540,1959072819,1160851460,821423097,807684968
Long mem#,964=-1480118224,842262154,-1245354119,1214534705,-1175293133,-1290138698,-1251331535,682898330,816886761,1928432115,-1280167886,-1003432360,-1294272294,1886565042,970371184,51853974,1421583616,334163600,79,1313163520
Long mem#,1044=1614982724,130
Bitte nicht vergessen, die Variable mem# zum Programmende wieder freizugeben (Dispose).
Declare hBild1&
hBild1& = CatchBmp(mem#)
Dispose mem#
Cls
*** Bild anzeigen
DrawPic hBild&, 250,180, 1
DrawPic hBild1&, 250,220, 1
while 1
waitinput
Case %key=2:Break
Endwhile
*** Bild freigeben
DeleteObject hBild&
DeleteObjectd1&
END
|
| | | | |
| | Frank Abbing | Die Funktion CatchBmp() macht das, was ihr Name verspricht. Sie erzeugt einen Grafikhandle aus einer Bmp-File. Nur Bmp, ja und Rle.
Probier mal die Daten (als Bitmap) ins Clipboard kopieren und mit Create("hPic".. und "&CLPBMP" laden. Ansonsten Tempfile. |
| | | | |
| | Thomas Freier | Frank, Danke per den Hinweis. Hatte die letzte Variante vor einer Weile gewählt und war mir nicht sicher ob es mit XProfan 11 jetzt auch anders possibile ist. Die BMP-Variante bleibt mir ja noch offen. |
| | | | |
| | | @Thomas: Ich habe das Problem nicht verstanden, ist es gelöst?
Andernfalls, geht es Dir darum, Bilddaten aus dem Speicher (mem#) einem hPic zuzuordnen, um dieses anzuzeigen? |
| | | | |
| | Andreas Miethe
| Mit einem kleinen Umweg klappt es auch mit PNG,JPG usw. Eben alles was die GPIPlus so laden kann.
Habe den Code mal um CatchImage erweitert KompilierenMarkierenSeparierenDeclare bereich#,x&,y&,z&,p&,text$
Def GetSysColor(1) !"USER32","GetSysColor"
SetTrueColor 1
Proc CatchBmp
Parameters MemPointer&
Declare hDC&, BITMAPFILEHEADER#, BMPInfo&, init&, hImage&
hDC& = External("user32.dll", "GetDC", External("user32.dll", "GetDesktopWindow"))
Dim BITMAPFILEHEADER#, 14
BITMAPFILEHEADER# = MemPointer&
BMPInfo& = MemPointer& + 14
init& = MemPointer& + Long(BITMAPFILEHEADER#, 10)
hImage& = External("gdi32.dll", "CreateDIBitmap", hDC&, BMPInfo&, 4, init&, BMPInfo&, 0)
External("user32.dll", "ReleaseDC", External("user32.dll", "GetDesktopWindow"), hDC&)
Dispose BITMAPFILEHEADER#
Return hImage&
EndProc
Proc CatchImage
Struct GdiplusStartupInput = GdiplusVersion&,DebugEventCallback&,SuppressBackgroundThread&,SuppressExternalCodecs&
Var GDIP& = ImportDll("Gdiplus.dll","")
Var OLE& = ImportDll("Ole32.dll","")
Var Kernel& = ImportDll("Kernel32.dll","")
Declare gdpsi#,gdiplusToken&,ImageObject&,GraphicObject&,pStream&,RetVal&
Parameters MemPointer&,Size&
GDIPlus starten
Dim gdpsi#,GdiplusStartupInput
gdpsi#.GdiplusVersion& = 1
gdpsi#.DebugEventCallback& = 0
gdpsi#.SuppressBackgroundThread& = 0
gdpsi#.SuppressExternalCodecs& = 0
GdiplusStartup(ADDR(gdiplusToken&),gdpsi#,0)
Dispose gdpsi#
Speicher bereitstellen
Var m_hBuffer& = GlobalAlloc(2,Size&)
Var pBuffer& = GlobalLock(m_hBuffer&)
RtlMoveMemory(pBuffer&,MemPointer&,Size&)
GlobalUnlock(m_hBuffer&)
Stream erzeugen
CreateStreamOnHGlobal(m_hBuffer&,1,Addr(pStream&))
GdipCreateBitmapFromStream(pStream&,Addr(ImageObject&))
hBitmap erzeugen
GdipCreateHBITMAPFromBitmap(ImageObject&,Addr(RetVal&),0)
aufräumen
Var Command& = Long(pStream&,0)
call(Long(Command&,8),pStream&)IStream.Release
GlobalFree(m_hBuffer&)
GdipDisposeImage(ImageObject&)
GdipDeleteGraphics(GraphicObject&)
GdiplusShutdown(gdiplusToken&)
FreeDll GDIP&
FreeDll OLE&
FreeDll Kernel&
Return RetVal&
EndProc
*** Hier stehen die Bilddaten aus bmp direkt im Quellcode.
Erstellt am 21. Februar 2010 mit dem XProfan Datengenerator, (C) Frank Abbing
Datei: E:profanXDatengeneratoricon4.bmp (originale Dateigröße: 1334 Bytes)
Declare mem#
Dim mem#,1336
Clear mem#
Long mem#,0=87444802
Long mem#,8=70647808,2621440,1048576,1048576,65536,8,16777216
Long mem#,44=16777216
Long mem#,52=-617349120,-617283329,-634060545,-600571649,-600637185,1545142527,-600506244,-583728897,1545142527,-583794563,-96861953,-432537345,-517537537,-264765185,-567017217,-130416385,-735444737,2082734335,2099445904
Long mem#,128=1533280402,-449380262,1478230271,-231210905,-971570945,-904593153,-971636481,-550174465,-550108929,-298319617,-566886145,1853423871,-382271382,1533083903,-585695137,-1190199041,-482934535,890568959,-499711937
Long mem#,204=1782513919,1617625218,-516489122,-197525249,-533200641,1566376191,1882980448,1899692172,1966538895,-600768363,1364721919,-1474887602,-1005256476,-415891202,-130481921,-853278465,-551288577,1092223231,-1558773674
Long mem#,280=-1491861280,-2025979675,-534183766,1396703487,1545076828,1819672702,-399048596,-500891393,1578762495,1075314814,1262420043,1634140244,-466288542,1920925951,-1474887569,705954021,-921370575,-650837761,-667614977
Long mem#,356=-482868993,1562050815,-348716931,-718601985,-365494017,-466222849,-214368001,-1875246849,-466091852,1664811263,-382205834,1948385535,-365363065,-786038529,-583663361,-483000065,-1305673473,-706477877,-1407647534
Long mem#,432=-499777302,-516554497,-925433601,1904017605,-113639311,-874970881,1259995335,739508310,1276772402,-466812838,2084831487,-499646315,101449983,151912454,403701768,1882849305,-398983030,-1858469633,-1642659658
Long mem#,508=-331874087,-672792321,-247922476,1545404671,-2092826502,-1592262494,1713373404,1732378757,1648754813,524404,1110638592,-449314740,1545208063,-432603012,-1758199553,1431699648,-752353191,-921435905,1429471487
Long mem#,584=-667811741,1482555647,1914765401,-1171390333,470941907,-550043617,-954859265,-453836545,225
Long mem#,1076=1012727808,84229453,134744069,1967226373,579105603,50594863,151852558,67567872,1752726585,235471643,856786757,704708870,405485445,50331744,1863673183,1783300609,-2138274210,198459,1351113842,1331298818,-2121495506
Long mem#,1160=67132233,879174755,1196163402,-1936946128,102370416,172115978,756030722,-1936946036,122782496,258370857,321999878,-1936946036,588010380,227109966,-1943240155,-1936946036,529220748,476806015,-1943586805,-1936946036
Long mem#,1240=1077578892,1477597053,-1936972199,-1936946036,389975180,343167551,-1936974217,-1936946036,1988922508,891849270,-1936946055,-1936946036,1653378188,1896568370,-1936946106,-1936946036,-1936946036,2048467305,-1936946036
Long mem#,1316=-1936946036,-1936946036,1683320417,-1936946036,35980
Declare hBild&
hBild& = CatchBmp(mem#)
Dispose mem#
Erstellt am 21. Februar 2010 mit dem XProfan Datengenerator, (C) Frank Abbing
Datei: E:profanXDatengeneratoricon4.png (originale Dateigröße: 1049 Bytes)
Dim mem#,1052
Clear mem#
Long mem#,0=1196314761,169478669,218103808,1380206665,268435456,268435456,776,254617600,50331731,1414287360,886832965,-13247489,-587254310,870121268,-15115140,-570477092,425491765,-13312513,-419480838,669122360,-13045505
Long mem#,84=-117492514,718602042,-1843102576,1532633981,937820004,-14919577,-956352270,365625111,-15284481,-536922657,955186998,1781980927,-369133202,1633378103,-115876353,-469823559,355811127,-2110266625,1616789354,937557867
Long mem#,164=-12913409,1566587104,1014008925,-1791266417,-587253899,1481723441,-32003868,-402713148,972619574,-14365185,1096164575,396615706,-1441486875,-520143225,1079204905,1813535870,-385911188,635633463,1260019326,1263802432
Long mem#,244=1734435391,1865803007,-1461354638,338309399,-15349249,-654363175,954466101,-14983811,-704694293,938147627,-13179649,-1867236877,954531642,-12885130,1955018985,971702050,-14233089,-469813539,766692150,-354101806
Long mem#,324=-486598228,920780598,1909967045,-100696719,-640956614,840584022,1280971820,769982234,-12288875,101071074,235472908,-1978656743,-385926544,982627896,-15229223,-673957652,972160998,-1575134086,-1579400573,543589656
Long mem#,404=1950508925,18018,859982856,2084103679,-419489188,882360375,-11119271,-906024749,878011156,1496504575,1921211992,783995681,-15590369,-939575329,-203103978
Long mem#,808=1181556736,215,1094994388,1671198804,-998047256,135581884,1698824587,559303210,-2061949941,565843825,1972999177,576100457,-305861628,-901494141,1443029221,1122088206,812290321,-110192895,426568442,-1468724370
Long mem#,888=-1299238848,-1356378529,1141805930,-1875271360,-1925762211,1355034015,-1068487656,-439958237,616940769,302751787,1720513640,1230391648,-194842313,167786353,867391540,1959072819,1160851460,821423097,807684968
Long mem#,964=-1480118224,842262154,-1245354119,1214534705,-1175293133,-1290138698,-1251331535,682898330,816886761,1928432115,-1280167886,-1003432360,-1294272294,1886565042,970371184,51853974,1421583616,334163600,79,1313163520
Long mem#,1044=1614982724,130
Bitte nicht vergessen, die Variable mem# zum Programmende wieder freizugeben (Dispose).
Declare hBild1&
hBild1& = CatchImage(mem#,sizeof(mem#))
Dispose mem#
*** Bild anzeigen
cls
DrawPic hBild&, 250,180, 1
DrawPic hBild1&, 250,220, 1
while 1
waitinput
Case %key=2:Break
Endwhile
*** Bild freigeben
DeleteObject hBild&
DeleteObject hBild1&
END
|
| | | Gruss Andreas ________ ________ ________ ________ _ Profan 3.3 - XProfanX2 Win 95,98,ME,2000,XP,Vista - Win 7 32 / 64 Bit ASUS X93S - Intel Core I7-NVIDIA GForce 540M 8GB Arbeitsspeicher Homepage : [...] | 22.02.2010 ▲ |
| |
| | Thomas Freier | Danke Andreas, Problem aus meiner Sicht optimal gelöst. Damit muß dann nicht erst ein Bild erzeugt werden, das anschließend wieder gelöscht wird. Auch catchBmp ist dann nicht mehr erforderlich. |
| | | | |
| | Andreas Miethe
| Beachte aber, dass die GDIPlus.dll erst ab XP ein Bestandteil von Windosw ist. Bei älteren Systemen muss (und darf) die Dll mitgeliefert werden !! |
| | | Gruss Andreas ________ ________ ________ ________ _ Profan 3.3 - XProfanX2 Win 95,98,ME,2000,XP,Vista - Win 7 32 / 64 Bit ASUS X93S - Intel Core I7-NVIDIA GForce 540M 8GB Arbeitsspeicher Homepage : [...] | 22.02.2010 ▲ |
| |
| | Frank Abbing | Vielleicht mal die Clipboard-Variante ausprobieren, wenn pre-XP sein soll. |
| | | | |
| | | Hab auch noch eine Variante per kleine Bilder: KompilierenMarkierenSeparierencls
var hPic&=createHPic.attention_png()
drawPic hPic&,100,10;0
drawPic hPic&,100,50;0
waitinput
end
proc createHPic.attention_png
var hPic&=create("hNewPic",16,16,0)
var data$=decode64("8+ThAPPk4QDz5OEA8+ThAPPk4QDz5OEA18jFADpwigA7Y3YA2cvHAPPk4QDz5OEA8+ThAPPk4QDz5OEA8+ThAPPk4QDz5OEA8+ThAPPk4QDz5OEA8+ThAER8lQAX3f8AFsb/AEZidADz5OEA8+ThAPPk4QDz5OEA8+ThAPPk4QDz5OEA8+ThAPPk4QDz5OEA8+ThAH1xcQAVxP4AOOn/ADjm/wAXntkAf3Jv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Fx+ABlcfAAZXHwAGVx8ABlcfQAZXH0AGVx9ABlcfAAaXHwAGl5+AB1cegA/S1QA5tfUAA==")
external("gdi32.dll","SetBitmapBits",hPic&,1024,addr(data$))
return hPic&
KompilierenMarkierenSeparierencls
var fle$=loadFile$("Beliebige Bilddatei","*.*")//datei die in funktion konvertiert werden soll
casenot fileExists(fle$) : end 1
var fnam$=translate$(substr$(fle$,len(fle$,"\"),"\"),".","_")
var hPic&=create("hPic",-1,fle$)
var x&=%bmpx
var y&=%bmpy
var c&=x&*y&*4
var m&=external("kernel32.dll","GlobalAlloc",64,c&)//64=gPTR
external("gdi32.dll","GetBitmapBits",hPic&,c&,m&)
clearClip
putClip "proc createHPic."+fnam$+"
var hPic&=create(qhNewPicq,"+str$(x&)+","+str$(y&)+",0)
var data$=decode64(q"+encode64(char$(m&,0,c&))+"q)
external(qgdi32.dllq,qSetBitmapBitsq,hPic&,"+str$(c&)+",addr(data$))
return hPic&
endproc
"
end
|
| | | | |
|
AnswerThemeninformationenDieses Thema hat 4 subscriber: |