|
Post by Rod on Mar 31, 2023 9:03:08 GMT -5
|
|
|
Post by held12345 on Mar 31, 2023 11:11:15 GMT -5
thanks for your help, but it doesn't work.
with a mask, no car: hm as ulong,_ 'mask bmp handle, and without a mask with a car.
no a mask, is car: 0 as ulong,_ 'mask bmp handle, and without a mask with a car.
it only works with: "TransparentBlt". how can you bring the rotated car into "TransparentBlt" please. Thanks greeting Attachments:
|
|
|
Post by Rod on Mar 31, 2023 11:33:18 GMT -5
Works for me, you keep saying it does not work despite the fact we know it does. Then, when we get to see the code, you have made errors. How about hunting down your own error? You will actually find that quite rewarding. Have a go.
|
|
|
Post by held12345 on Mar 31, 2023 12:00:52 GMT -5
i took your code only the address of the bmp adapted to mine, nothing more.
Thanks. greeting
|
|
|
Post by Rod on Mar 31, 2023 12:36:58 GMT -5
So what fails on your system? Remember each call returns a success or failure value. Precision is important. Only you can debug this so step through and find what line is actually failing.
For example did you put the bmps in the directory changes you made?
|
|
|
Post by held12345 on Mar 31, 2023 15:07:42 GMT -5
this is the demo from forum here.
the mask does not produce a transparent image for me. Why not?
auto24bit.bmp and mask1bit.bmp
Thanks greeting
loadbmp "image","auto24bit.bmp" hImage=hbmp("image") struct BITMAP,_ bmType as long,_ bmWidth As long,_ bmHeight As long,_ bmWidthBytes As long,_ bmPlanes as word,_ bmBitsPixel as word,_ bmBits as Long length=len(BITMAP.struct) calldll #gdi32, "GetObjectA", hImage as ulong,_ length as long,BITMAP as struct,_ results as long bmpWidth=BITMAP.bmWidth.struct bmpHeight=BITMAP.bmHeight.struct 'need monochrome bmp 'create black and white bmp and save to disk 'use LoadImageA with monochrome flag set ' to assure handle to monochrome bmp imagePath$=DefaultDir$;"mask1bit.bmp" flags = _LR_MONOCHROME or _LR_LOADFROMFILE calldll #user32, "LoadImageA",_ 0 as ulong,_ 'instance - use 0 for image from file imagePath$ as ptr,_ 'path and filename of image _IMAGE_BITMAP as long,_ 'type of image bmpWidth as long,_ 'desired width bmpHeight as long,_ 'desired height flags as long,_ 'load flags hMask as Ulong 'handle of loaded image nomainwin winWide=700:winHigh=500 WindowWidth=winWide+50:WindowHeight=winHigh+50 UpperLeftX=1:UpperLeftY=1 graphicbox #1.g, 0,0,winWide,winHigh open "Masked Parallelogram Blt" for window as #1 #1 "trapclose [quit]" #1.g "down;fill blue" h=hwnd(#1.g) 'graphicbox handle 'get device context for window: calldll #user32, "GetDC",_ h as ulong,_ 'graphicbox handle hdc as ulong 'returns handle to device context CallDLL #gdi32,"CreateCompatibleDC",_ hdc as uLong,_ memdc as uLong CallDLL #gdi32,"SelectObject",_ memdc as uLong,_ hImage as uLong,_ oldObject as uLong STRUCT lpPoint,_ x1 as long,_ 'ulx y1 as long,_ 'uly x2 as long,_ 'urx y2 as long,_ 'ury x3 as long,_ 'llx y3 as long 'lly 'The STRUCT must be filled before it can be used in an api call: lpPoint.x1.struct = int(winWide/2) lpPoint.y1.struct = 0 lpPoint.x2.struct = winWide lpPoint.y2.struct = int(winHigh/2) lpPoint.x3.struct = 0 lpPoint.y3.struct = int(winHigh/2) calldll #gdi32, "PlgBlt",_ hdc as ulong,_ 'device context of graphicbox lpPoint as struct,_ 'array of points memdc as ulong,_ 'memory DC 0 as long,_ 'ulx source 0 as long,_ 'uly source bmpWidth as long,_ 'width source bmpHeight as long,_ 'height source hMask as ulong,_ 'mask monochrome bmp handle 0 as long,_ 'ulx mask 0 as long,_ 'uly mask re as long 'nonzero=success 'method to flush GDI graphics: '#1.g "getbmp pix 0 0 ";winWide;" ";winHigh '#1.g "drawbmp pix 0 0;flush" wait [quit] calldll #user32, "ReleaseDC",_ h as ulong,_ 'window handle hdc as ulong,_ 'device context ret as long CallDLL #gdi32, "DeleteDC",memdc as uLong, r As long close #1:end[/div][div]
Attachments:
|
|
|
Post by Rod on Apr 1, 2023 4:44:44 GMT -5
It may be a couple of things. Firstly Liberty does not know all of the Windows constants so sometimes you have to use literal numbers. Also DefaultDir$ seemed to be causing the bmp not to be found. Thats why you got a full black background because the image you created was all white.
So by making sure the API call gets the bmp and by replacing the constants with literals it works.
'need monochrome bmp 'create black and white bmp and save to disk 'use LoadImageA with monochrome flag set 'to assure handle to monochrome bmp
imagePath$="mask1bit.bmp" flags = 1 or 16
calldll #user32, "LoadImageA",_ 0 as ulong,_ 'instance - use 0 for image from file imagePath$ as ptr,_ 'path and filename of image _IMAGE_BITMAP as long,_ 'type of image bmpWidth as long,_ 'desired width bmpHeight as long,_ 'desired height flags as long,_ 'load flags hMask as Ulong 'handle of loaded image
However there should be no need to do this because we are just creating the original bmp. If the code could find the original mask1bit.bmp it would work without the loadimageA()
|
|
|
Post by held12345 on Apr 1, 2023 11:45:14 GMT -5
I have now found something with pglblt. where does this variable come from, how is it assembled?
#1.g "home ; posxy dialMidX dialMidY"
why can't you make this picture dial.bmp in 2x bmp?
loadbmp "dial","sprites\dial.bmp" dialImage=hbmp("dial")
dialWidth=200 dialHeight=200 imagePath$="sprites\mask.bmp" flags = _LR_MONOCHROME or _LR_LOADFROMFILE calldll #user32, "LoadImageA",_ 0 as ulong,_ imagePath$ as ptr,_ _IMAGE_BITMAP as long,_ dialWidth as long,_ dialHeight as long,_ flags as long,_ maskImage as Ulong nomainwin WindowWidth=800 WindowHeight=600 UpperLeftX=(DisplayWidth-WindowWidth)/2 UpperLeftY=(DisplayHeight-WindowHeight)/2 graphicbox #1.g, 0,0,WindowWidth,WindowHeight open "Parallelogram Blt" for window as #1 #1 "trapclose [quit]"
#1.g "down;fill lightgray" #1.g "getbmp buf 0 0 800 600"
bufImage=hbmp("buf")
#1.g "home ; posxy dialMidX dialMidY"
dialX=int(dialMidX-dialWidth/2) dialY=int(dialMidY-dialHeight/2) h=hwnd(#1.g) calldll #user32, "GetDC",_ h as ulong,_ hdc as ulong calldll #gdi32,"CreateCompatibleDC",_ hdc as uLong,_ memdc as uLong
CallDLL #gdi32,"SelectObject",_ memdc as uLong,_ dialImage as uLong,_ oldObject as uLong
calldll #gdi32,"CreateCompatibleDC",_ memdc as uLong,_ bufdc as uLong
CallDLL #gdi32,"SelectObject",_ bufdc as uLong,_ bufImage as uLong,_ oldObject as uLong
STRUCT lpPoint,_ x1 as long,_ 'ulx y1 as long,_ 'uly x2 as long,_ 'urx y2 as long,_ 'ury x3 as long,_ 'llx y3 as long 'lly
angle=45
timer 100, [draw] wait
[draw]
CallDll #gdi32, "BitBlt",_ hdc as ulong,_ 'The destination DC 0 as long,_ 'x location on destination 0 as long,_ 'y location on destination 800 as long,_ 'width to transfer 600 as long,_ 'height to transfer bufdc as ulong,_ 'The source DC 0 as long,_ 'x location in source 0 as long,_ 'y location in source _SRCCOPY as ulong,_ 'dwRasterOperation result as long
CallDll #gdi32, "BitBlt",_ bufdc as ulong,_ dialX as long,_ dialY as long,_ dialWidth as long,_ dialHeight as long,_ memdc as ulong,_ 200 as long,_ 0 as long,_ _SRCCOPY as ulong,_ result as long angle=angle+1 if angle=361 then angle=1
lpPoint.x1.struct=dialMidX-(150*cos(angle/57.29577951)) lpPoint.y1.struct=dialMidY-(150*sin(angle/57.29577951)) lpPoint.x2.struct=dialMidX-(150*cos((angle+90 mod 360)/57.29577951)) lpPoint.y2.struct=dialMidY-(150*sin((angle+90 mod 360)/57.29577951)) lpPoint.x3.struct=dialMidX-(150*cos((angle+270 mod 360)/57.29577951)) lpPoint.y3.struct=dialMidY-(150*sin((angle+270 mod 360)/57.29577951))
calldll #gdi32, "PlgBlt",_ bufdc as ulong,_ 'device context of graphicbox lpPoint as struct,_ 'array of points memdc as ulong,_ 'memory DC 0 as long,_ 'ulx source 0 as long,_ 'uly source dialWidth as long,_ 'width source dialHeight as long,_ 'height source maskImage as ulong,_ 'mask bmp handle, null = not used 0 as long,_ 'ulx mask 0 as long,_ 'uly mask re as long 'nonzero=success
wait
[quit] calldll #user32, "ReleaseDC",_ h as ulong,_ hdc as ulong,_ ret as long CallDLL #gdi32, "DeleteDC",memdc as uLong, r As Boolean CallDLL #gdi32, "DeleteDC",bufdc as uLong, r As Boolean close #1:end
Attachments:dial.bmp (234.42 KB)
|
|
|
Post by Rod on Apr 1, 2023 12:14:23 GMT -5
Spoon feeding does not feel rewarding. You could find this for yourself. Home puts the cursor at the centre of the current graphicbox. Posxy returns those x,y coordinates. If you were going to double the size of the image where would the new mid point be and what would x,y return?
|
|
|
Post by Rod on Apr 1, 2023 13:07:39 GMT -5
Each of these graphic tools have certain capabilities. Blit is fairly bland Stretchblit can do more, Transparentblit can do some of what Stretchblit can but not all. Plgblt can rotate but can’t do all of the same tricks as Stretchblit or Transparentblit. So you need to chart a way through to achieve what you want with the graphic.
You could draw the buffer half size and expand the final blit to screen.
|
|
|
Post by held12345 on Apr 1, 2023 13:13:45 GMT -5
it now works to rotate and show the car on the screen at 74 years old i am stubborn and stubborn.
but thanks to you for the thema help with this topic.
use q/w/e/s to move and turn the car. with a/d you can zoom in and out of the car
Thanks. greeting
nomainwin open "Msimg32.dll" for DLL as #m
winWide=180:winHigh=180
WindowWidth=800 WindowHeight=500 UpperLeftX=10:UpperLeftY=10
graphicbox #1.g, 10,10,winWide,winHigh graphicbox #1.g1, 200,10,500,300
open "Parallelogram Blt" for window as #1 #1 "trapclose [quit]"
loadbmp "image","sprites\auto11.bmp" hImage=hbmp("image") struct BITMAP,_ bmType as long,_ bmWidth As long,_ bmHeight As long,_ bmWidthBytes As long,_ bmPlanes as word,_ bmBitsPixel as word,_ bmBits as Long length=len(BITMAP.struct) calldll #gdi32, "GetObjectA", hImage as ulong,_ length as long,BITMAP as struct,_ results as long bmpWidth=BITMAP.bmWidth.struct bmpHeight=BITMAP.bmHeight.struct loadbmp "image1","sprites\large.bmp" hImage1=hbmp("image1") struct BITMAP,_ bmType as long,_ bmWidth1 As long,_ bmHeight1 As long,_ bmWidthBytes As long,_ bmPlanes as word,_ bmBitsPixel as word,_ bmBits as Long length=len(BITMAP.struct) calldll #gdi32, "GetObjectA", hImage1 as ulong,_ length as long,BITMAP as struct,_ results as long bmpWidth1=BITMAP.bmWidth1.struct bmpHeight1=BITMAP.bmHeight1.struct
h=hwnd(#1.g) h1=hwnd(#1.g1)
calldll #user32, "GetDC",_ h1 as ulong,_ hdc1 as ulong CallDLL #gdi32,"CreateCompatibleDC",_ hdc1 as uLong,_ memdc1 as uLong
CallDLL #gdi32,"SelectObject",_ memdc1 as uLong,_ hImage1 as uLong,_ oldObject1 as uLong
'----------------------------------------
calldll #user32, "GetDC",_ h as ulong,_ hdc as ulong CallDLL #gdi32,"CreateCompatibleDC",_ hdc as uLong,_ memdc as uLong
CallDLL #gdi32,"SelectObject",_ memdc as uLong,_ hImage as uLong,_ oldObject as uLong
STRUCT lpPoint,_ x1 as long,_ 'ulx y1 as long,_ 'uly x2 as long,_ 'urx y2 as long,_ 'ury x3 as long,_ 'llx y3 as long 'lly
x1=-1*bmpWidth/2:y1=-1*bmpHeight/2 x2=1*bmpWidth/2:y2=-1*bmpHeight/2 x3=-1*bmpWidth/2:y3=1*bmpHeight/2
r = 1 pi=acs(-1) cx=winWide/2:cy=winHigh/2
xstr=180
TIMER 10, [keyCheck] wait
[keyCheck] if keyState(83) then dx=cos(aa) dy=sin(aa) x=x+dx*2 y=y+dy*2 end if
if keyState(87) then dx=cos(aa) dy=sin(aa) x=x-dx*2 y=y-dy*2 end if
if keyState(81) then a=a-5 end if
if keyState(69) then a=a+5 end if if keyState(65) then xstr=xstr-1 end if if keyState(68) then xstr=xstr+1 end if
gosub [drehe] wait [drehe] #1.g "down;fill black" aa=a*pi/180 c=cos(aa):s=sin(aa) lpPoint.x1.struct = int(cx+r*(c*x1-s*y1)) lpPoint.y1.struct = int(cy+r*(s*x1+c*y1)) lpPoint.x2.struct = int(cx+r*(c*x2-s*y2)) lpPoint.y2.struct = int(cy+r*(s*x2+c*y2)) lpPoint.x3.struct = int(cx+r*(c*x3-s*y3)) lpPoint.y3.struct = int(cy+r*(s*x3+c*y3)) result=blit(hdc1,0,0,500,300,memdc1,0,0) calldll #gdi32, "PlgBlt",_ hdc as ulong,_ 'device context of graphicbox lpPoint as struct,_ 'array of points memdc as ulong,_ 'memory DC 0 as long,_ 'ulx source 0 as long,_ 'uly source bmpWidth as long,_ 'width source bmpHeight as long,_ 'height source 0 as ulong,_ 'mask bmp handle, null = not used 0 as long,_ 'ulx mask 0 as long,_ 'uly mask re as long 'nonzero=success CallDll #m, "TransparentBlt",_ hdc1 as ulong,_ 'The destination DC = graphicbox x as long,_ 'x location on destination y as long,_ 'y location on destination xstr as long,_ 'width to stretch to xstr as long,_ 'height to stretch to hdc as ulong,_ 'The source DC = memory 0 as long,_ 'x location in source 0 as long,_ 'y location in source 180 as long,_ 'width to take from source 180 as long,_ 'height to take from source lColor as ulong,_ 'RGB/long color value to make transparent result as long 'nonzero if successful wait
function keyState(keycode) calldll #user32, "GetAsyncKeyState", _ keycode AS long, _ keyState AS long end function function blit(dDC,x,y,w,h,sDC,sx,sy) CallDll #gdi32, "BitBlt", _ dDC as ulong,_ 'The destination DC x as long,_ 'x location on destination y as long,_ 'y location on destination w as long,_ 'width to transfer h as long,_ 'height to transfer sDC as ulong,_ 'The source DC sx as long,_ 'x location in source sy as long,_ 'y location in source _SRCCOPY as ulong,_ 'The operation to be performed blit as long 'nonzero if successful end function
[quit] calldll #user32, "ReleaseDC",_ h as ulong,_ 'window handle hdc as ulong,_ 'device context ret as long
CallDLL #gdi32, "DeleteDC",memdc as uLong, r As long close #1:end
Attachments:
|
|
|
Post by held12345 on Apr 2, 2023 11:34:58 GMT -5
liberty basic is a strong good program.
here ist thes bmp for the demo.
greeting
Attachments:auto11-larde.zip (13.5 KB)
|
|