dkl
Full Member
Posts: 234
|
Post by dkl on Mar 2, 2021 20:37:58 GMT -5
Is there a way I can convert/save Jpg's to Bmp's within an LB programme?
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Mar 2, 2021 21:22:18 GMT -5
PBImage.dll appears to be able to save a .jpg to .bmp, but I'm not sure if its a true BMP. what software can I use to read/check the metadata of an image to tell what format it is?
|
|
|
Post by Rod on Mar 3, 2021 4:05:39 GMT -5
Not sure why we need to convert the image when you can easily load it. Untested code but you will get the idea.
'put this at the top of your program 'and the functions with your other functions at the foot of the program open "gdiplus.dll" for dll as #gdip
'now at the point you httpget$(), check what you got if left$(f$,2)="BM" then 'we have a bmp
'do your normal .bmp write and load and display
else
'write the file as .jpg and use this code to load and display it
hBmp=LoadImgFromFile("filename.jpg") if hBmp<>0 then loadbmp "pic",hBmp print #main.g, "drawbmp pic 0 0;flush" unloadbmp "pic" 'Because LB doesnt delete it for us calldll #gdi32,"DeleteObject",hBmp as ulong, ret as ulong else notice "Could not load the image file!" end if end if
wait
function wchar$(string$) for i = 1 to len(string$) wchar$=wchar$+mid$(string$,i,1)+chr$(0) next i wchar$=wchar$+chr$(0)+chr$(0) end function
function LoadImgFromFile(file$) struct dword,a as ulong gdistart$=chr$(1) for i = 1 to 15 gdistart$=gdistart$+chr$(0) next i calldll #gdip,"GdiplusStartup",dword as struct,gdistart$ as ptr,status as ulong token=dword.a.struct if status<>0 then LoadImgFromFile=0
else wFileLoc$=wchar$(file$) calldll #gdip,"GdipCreateBitmapFromFile", _ wFileLoc$ as ptr,dword as struct,status as ulong hPic=dword.a.struct if status<>0 then LoadImgFromFile=0 else calldll #gdip,"GdipCreateHBITMAPFromBitmap", _ hPic as ulong,dword as struct,0 as ulong,status as ulong hBmp=dword.a.struct if status<>0 then LoadImgFromFile=0 else LoadImgFromFile=hBmp end if calldll #gdip,"GdipDisposeImage",hPic as ulong,ret as ulong end if calldll #gdip,"GdiplusShutdown",token as ulong,ret as ulong end if end function
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Mar 3, 2021 17:27:35 GMT -5
I was asking more out of curiosity than necessity, but I'm working with sets of data, one is my LB programme (on my desktop) which uses .bmp files and GlideApps (on my iphone) which uses .jpg files. It would be easier to sync the 2 with my iPhone data as that's the version I use most. But it's not vital! I just don't have any understanding of DLL calls and API's etc, which is why I asked! It's also why I got muddled een .jpg and .bmp when accessing the image files! Thanks for your help once again and I'll study your code above
|
|
|
Post by Rod on Mar 4, 2021 2:42:16 GMT -5
Well there are .dll utilities. John has examples on his site. But since you have loaded it into Liberty it has become a bmp. So savebmp is the command you would need if you are converting .jpg to .bmp. You would need a helper .dll if you are converting a .bmp to a .jpg
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Mar 8, 2021 1:08:20 GMT -5
I got the programme working using .jpg, but would be interested in the other.dll utilies you mentioned, but I don't know who John is or the address of his website! Perhaps you could enlighten me please?
Using the copy command in the LB texteditor has always baffled me! I can get the command to work using 'selectall' within the texteditor, but don't seem to be able to get it to work for single lines unless I manually highlight and copy it.
I have an array that is printed into the texteditor, which I would also like to go straight into the the clipboard to print elsewhere outside of LB, how can I get the array to go automatically into the clipboard?
|
|
|
Post by Rod on Mar 8, 2021 4:29:35 GMT -5
Everything you need to know about the clipboard is listed in the newsletter. There are two parts, Native and API. www.libertybasicuniversity.com/lbnews/nl108/tip.htmThe reason you are finding it difficult is that you are using the textedit control in reverse. It is designed for user input and interaction, the user is supposed to highlight the text not the program. Thats why it has few tools to highlight text. John has his own web resource and has used imagemagic a lot. www.diga.me.uk/IM.html
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Mar 11, 2021 22:05:53 GMT -5
Thanks for the help Rod and the links. I ended up using a 'hidden' textbox which I have done before and it does the trick However, it doesn't want to hide!! Used the info supplied - texteditor #1.hide, -400,-400,0,0 - but it appears behind my other other GUI window at the same size - It emulates it! I've tried using the "hide" statement, but it won't hide! The moment it gets a 'call' it jumps in front of the 'working' programme.
I think this present programme is jinked,
I wanted to use a combobox for an action, but it wouldn't recognise any input either and I've used them plenty of times without any problems. I even wrote a seperate combobox sample programme to test my commands and it worked fine - stick it back into the programme and it doesn't work!
Duh! My brains gone dead!
|
|
|
Post by tsh73 on Mar 11, 2021 23:28:37 GMT -5
once I had misterious case of text editor not responding After all, happens to be duplicated line - I had two texteditors with same handle one atop other
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Mar 12, 2021 2:23:50 GMT -5
well this is the code i'm using
[GUI] 'nomainwin WindowWidth = 500 WindowHeight = 500 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
texteditor #main.te, 290,10,185,390 texteditor #1.hide, -400,-400,0,0'<- invisible texteditor used as clipboard code from alyce watson demo
open "clipboard" for window as #1 open "IMDb Search" for window as #main
wait
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Mar 12, 2021 2:28:19 GMT -5
AH ..... I should be using 1 handle NOT two, but different names! well, that's sorted one problem hopefully!
|
|