On 8/10/2010 11:24, Raul Miller wrote:
> On Tue, Aug 10, 2010 at 11:00 AM, Raul Miller<[email protected]>  wrote:
>> So... I use gethttp to retrieve a png image which I want to manipulate in J.
>>
>> png=:gethttp'http://rosettacode.org/mw/images/c/c6/Pentagon.png'
>
> Apparently this is a part of the problem.
>
> gethttp is corrupting the image.
>
> So another question is: do we have a reliable equivalent to gethttp?
>
> Thanks,
>

How about this (quick and dirty and needs bullet proofing):

require 'socket files media/platimg'
coinsert 'jsocket'

getPent=: 3 : 0
rosettac=. sdcheck sdgethostbyname 'rosettacode.org'  NB. find host
skr=. 0 pick sdcheck sdsocket ''
sdcheck sdconnect skr;rosettac,<80  NB. connect to port 80
sdcheck ('GET http://rosettacode.org/mw/images/c/c6/Pentagon.png',CR,LF) sdsend 
skr,0
qqq=.;sdcheck sdrecv skr,10000,0
sdcheck sdclose skr
qqq fwrite 'C:\temp\Pentagon.png'
qqq
)

    foo=:getPent''

    bitmap=:getimg foo

    $bitmap
240 320

--
David Mitchell
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to