|
Post by honkytonk on Nov 29, 2022 11:29:20 GMT
Hello, Why does JB/LB not manage the ".jpg" in simple import / display? What is the difficulty? Isn't it possible for JB/LB to convert internally?
".BMP" is so heavy.
|
|
|
Post by tsh73 on Nov 29, 2022 12:14:15 GMT
As to "why" it is a problem of being "good enough" And - LB definitely has less problem - it could use DLLs, and there are DLLs to convert other formats.
As to difficulty doing it all pixel by pixel in JB/LB is rather pointless because 1) it would be damn slow 2) BMP is really simple, but other formats use math noone ported to JB/LB yet (but I have somewhere native GIF decoder ib JB, by AndyAmaya I recon) 3) wheel is already invented
I found this little command line converter in JB archive
And I pretty sure it just has single Windows API call inside ("wheel is already invented", you see?)
So you could save some space distributing your program. But to actually *use* these pictures you'll need them as BMP anyway.
|
|
|
Post by plus on Nov 29, 2022 13:09:10 GMT
As I recall Paint does nice job converting different formats.
|
|
|
Post by tsh73 on Nov 29, 2022 13:41:26 GMT
As I recall Paint does nice job converting different formats. it would be really priceless if it coud be scripted from the command line. Like, "I want this piece (top, left, width, height) from the middle of that big PNG with character sheets, saved as BMP and with mask added" Oh wait. It is already here and is called ImageMagick. (Well may be without mask part though I'm not sure) Only problem it is not installed by default.
|
|
|
Post by plus on Nov 29, 2022 15:06:26 GMT
Paint does that too unless you are talking of taking a snap shot of a running JB program? Sounds like a job for xxgeek?
|
|
|
Post by Rod on Nov 29, 2022 15:53:14 GMT
.bmp is a pixel perfect, native screen format, Just BASIC has to support .bmp. Then there is a slew of other formats, gif, png, pic, raw, jpg, tiff, heic. Where to start where to stop? Sensibly at .bmp?
|
|
|
Post by xxgeek on Nov 29, 2022 19:32:34 GMT
Paint does that too unless you are talking of taking a snap shot of a running JB program? Sounds like a job for xxgeek? A job? No thanks, I'm retired and happy being retired. But on the hobby side of things.... Rod just posted a link to the MS virtual key constants in another thread. learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codesI see there is a key constant for print screen too. VK_SNAPSHOT 0x2C PRINT SCREEN key Along with a key for [enter] or Return VK_RETURN 0x0D ENTER key See Using Virtual Key Constants" in the JB help for info on coding these keys in JB. Also there are a few 3rd party tools that use the commandline for editting pictures. JB can write and execute scripts.
|
|
|
Post by honkytonk on Nov 30, 2022 17:32:30 GMT
Nor is there a way with the "Screen saver" which is somewhere on the forum, to measure the image (".jpg" or other), to put it in memory (not visible) and to re-import it in ".bmp" ?
|
|
|
Post by Rod on Nov 30, 2022 19:49:55 GMT
Everything you mention can be accomplished with Liberty BASIC. You can load any type of graphic and snapshot any portion of the screen. Perhaps it is time for you to upgrade.
|
|
|
Post by honkytonk on Dec 1, 2022 8:46:05 GMT
I found this (to put in a folder):
nomainwin leftX = 1: leftY = 1 rightX = DisplayWidth: rightY = DisplayHeight
call screenShot 1,1,DisplayWidth,DisplayHeight bmpsave "Snapshot", "screenshot.bmp" notice, "snapshot is in the folder"
Sub screenShot xOrgSrc,yOrgSrc,xExtent,yExtent 'x and y OrgSrc is the upperleft corner where our bitmap starts hdcScr=createDC("DISPLAY",null$(1),null$(1),null$(1)) 'we create a device context for the screen hdcCom=createCompatibleDC(hdcScr) 'then we create a compatible device context hbmScr=createCompatibleBitmap(hdcScr,xExtent,yExtent) 'then we need a compatible bitmap hmemBmp=selectObject(hdcCom,hbmScr) 'now we select the bitmap into the device context Call bitBlt hdcCom,0,0,xExtent,yExtent,hdcScr,xOrgSrc,yOrgSrc,_SRCCOPY 'here we copy the screen bit by bit into the device context hdcScr=selectObject(hdcCom,hmemBmp) 'we have to release the bitmap to use it in LB LoadBmp "Snapshot", hdcScr 'load the bitmap into LB Call deleteObject hmemBmp 'release resources to prepare for the next shot Call deleteDC hdcScr Call deleteDC hdcCom End Sub Sub bitBlt hDestDC,x,y,nWidth,nHeight,hSrcDC,xSrc,ySrc,dwRop CallDLL #gdi32,"BitBlt",_ hDestDC As ulong,_ 'destination dc for the bit transfer x As long,_ 'x coordinate for upper left corner of destination y As long,_ 'y coordinate for upper left corner of destination nWidth As long,_ 'width of both source and destination nHeight As long,_ 'height of both source and destination hSrcDC As ulong,_ 'source dc for the bit transfer xSrc As long,_ 'x coordinate to begin bit transfer from source ySrc As long,_ 'y coordinate to begin bit transfer from source' dwRop As long,_ 'type of transfer (source copy, merge, etc.) ret As long End Sub Function createCompatibleBitmap(hdc,nWidth,nHeight) CallDLL #gdi32,"CreateCompatibleBitmap",_ hdc As ulong,_ 'the handle to the compatible DC nWidth As long,_ 'width of the bitmap nHeight As long,_ 'height of the bitmap createCompatibleBitmap As ulong 'the functions return is the handle to the compatible bitmap End Function Function selectObject(hdc,hObject) CallDLL #gdi32,"SelectObject",_ hdc As ulong,_ 'handle of the compatible DC to select the compatible bitmap into hObject As ulong,_ 'handle of the compatible bitmap to select, or the handle to the selected bitmap to release selectObject As ulong End Function Function createDC(lpDriverName$,lpDeviceName$,lpOutput$,lpInitData$) 'DC = device context CallDLL #gdi32, "CreateDCA",_ lpDriverName$ As ptr,_ 'this is the only parameter we use here, the rest are passed as null strings lpDeviceName$ As ptr,_ lpOutput$ As ptr,_ lpInitData$ As ptr,_ createDC As ulong 'this function returns the handle to the display DC that is created End Function Function createCompatibleDC(hdc) CallDLL #gdi32,"CreateCompatibleDC",_ hdc As ulong,_ 'this is the handle to our display device context createCompatibleDC As ulong 'this function returns the handle of the compatible DC that is created End Function Sub SetBkMode hDC, flag '1=transparent '2=opaque CallDLL #gdi32, "SetBkMode",hDC As ulong,_ flag As long, RESULT As long End Sub Function GetDC(hWnd) CallDLL #user32, "GetDC",hWnd As ulong,_ GetDC As ulong End Function Sub ReleaseDC hWnd, hDC CallDLL#user32,"ReleaseDC",hWnd As ulong,_ hDC As ulong,result As long End Sub Sub deleteObject hObject CallDLL #gdi32,"DeleteObject",_ hObject As ulong,_ 'delete the selected object to free up resources ret As long End Sub Sub deleteDC hdc CallDLL #gdi32,"DeleteDC",_ hdc As ulong,_ 'handle to dc used to free up resources when dc is no longer needed ret As long End Sub
But how to load a non ".bmp" image into memory? And then the management of the dll seems very difficult to me. Where can I find a dll course?
|
|
|
Post by Rod on Dec 1, 2022 10:19:30 GMT
|
|
|
Post by honkytonk on Dec 1, 2022 17:26:02 GMT
Big thank for the links
|
|