Page 2 of 3
Posted: Sun Oct 07, 2007 11:57 pm
by Ollivier
Don't worry
There's only 3 commands:
Grab, resize and ImageOutput.
>> Which command you want to execute, actually?
Posted: Mon Oct 08, 2007 12:31 pm
by PB
> Which command you want to execute, actually?
If you're talking to me, then I want to be able to use all Image commands
with this tip. ImageWidth(), ImageHeight(), etc.
Posted: Mon Oct 08, 2007 12:37 pm
by srod
You'll note that netmaestro's functions actually draw the image retrieved from gdi+ directly onto a PB image.
If you simply replace the two instances of
with
then you should have what you're after.
Posted: Mon Oct 08, 2007 12:41 pm
by PB
Nope, still can't get it. Changed the ProcedureReturn as you said, and I'm
calling it like this:
And then using ImageWidth(f) gives "#Image object not initialized".
I'm not thinking right tonight so maybe I'm missing the obvious?
Posted: Mon Oct 08, 2007 12:44 pm
by srod
Let me have a go (must admit that I didn't try it!)

Posted: Mon Oct 08, 2007 12:47 pm
by srod
Works fine here PB.
With the changes mentoned above :
Code: Select all
Debug ImageWidth(ImageFromFile("open.ico"))
displayed the correct width of the icon I gave it.
**EDIT - yep, works with png's, jpegs,...
Posted: Mon Oct 08, 2007 12:49 pm
by srod
Hey,
did you change BOTH ProcedureReturn()'s; one in each of the two relevant procedures ?

Posted: Mon Oct 08, 2007 10:17 pm
by PB
I was only using ImageFromFile() so I only changed it there. But, it's now
working (after a quick rewrite of my test app) so I don't know what I was
doing wrong before.

Thanks for your help and advice.
Posted: Tue Oct 09, 2007 12:37 am
by dontmailme
I missed this too
another winner from netmaestro

Posted: Tue Oct 09, 2007 1:06 am
by Ollivier
I must learn again to read...
I stopped my reading to the ImageID() without reading the expression between brackets.
2 BP
Excuse me for the lost time... I remember for the next time to prevent me from stay at only one false idea...
Posted: Tue Oct 09, 2007 1:13 am
by netmaestro
Sorry I have so little time for the forums just now, big thanks to srod for lending support. I'm looking forward to having more time in a couple of weeks.
Re: Get more image formats with less overhead
Posted: Thu Sep 29, 2011 12:28 am
by Joakim Christiansen
Any way to get this working with newest PB?
Re: Get more image formats with less overhead
Posted: Thu Sep 29, 2011 1:04 am
by netmaestro
Any way to get this working with newest PB?
Using 4.60 RC1 I tested both procedures with a .jpg image and got success. Is there a problem?
Re: Get more image formats with less overhead
Posted: Thu Sep 29, 2011 3:22 am
by Joakim Christiansen
netmaestro wrote:Any way to get this working with newest PB?
Using 4.60 RC1 I tested both procedures with a .jpg image and got success. Is there a problem?
A problem with ImageFromMem it seems!
Try changing CompilerIf 1 to 0 and it will not load the image correctly.
Code: Select all
IncludeFile "gdiplus.decoder.pb"
EnableExplicit
Procedure receiveHTTPMemory(URL$) ;silly one ;P
Protected *memory
ReceiveHTTPFile(URL$,GetTemporaryDirectory()+"imgdown")
If ReadFile(0,GetTemporaryDirectory()+"imgdown")
*memory = AllocateMemory(Lof(0))
ReadData(0,*memory,Lof(0))
CloseFile(0)
EndIf
ProcedureReturn *memory
EndProcedure
InitNetwork()
CompilerIf 1 ;1=fromFile, 0=fromMem
ReceiveHTTPFile("http://umbra.nascom.nasa.gov/images/latest_aia_171.gif","test.gif")
Define img_image1 = ImageFromFile("test.gif")
CompilerElse
Define *image1 = receiveHTTPMemory("http://umbra.nascom.nasa.gov/images/latest_aia_171.gif")
Define img_image1 = ImageFromMem(*image1,MemorySize(*image1))
CompilerEndIf
OpenWindow(0,0,0,600,600,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ImageGadget(0,0,0,600,600,ImageID(img_image1))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
And yes, I've changed your code to ProcedureReturn imagenumber

Re: Get more image formats with less overhead
Posted: Thu Sep 29, 2011 4:00 am
by netmaestro
Sorry, it seems there was a bug in it from the beginning, but it only shows up if you use AllocateMemory() to save the image in memory as opposed to using a datasection. First post is fixed, please try it now and again, sorry for any inconvenience.
Also, please note that both procs return imagenumber now, so using ImageID() on the return value of both is required. I don't know why I posted a pair of procedures with two different uses for the returns in the first place, that was a mistake.