Re: How to access raw data (as seen in chevron syntax) A sketch for a solution to get the picture format data out of the clipboard.
Re: How to access raw data (as seen in chevron syntax) A sketch for a solution to get the picture format data out of the clipboard.
- Subject: Re: How to access raw data (as seen in chevron syntax) A sketch for a solution to get the picture format data out of the clipboard.
- From: Tommy Bollman <email@hidden>
- Date: Sat, 3 Jul 2010 01:04:42 +0200
About getting the picture data:
How about coercing the clipboard to a record, presumably you have Script Debugger so that you can see the properties, of the record returned.
Then write the so and so many bytes as unicode text (text) to a file of class utf16, then you could read back the the parts you wanted as string and convert
them to number as you see fit, (Hex-Edit may help you with the interpretation - finding the correct offsets in the contents of that file) . It would of course be a painfully slow process, but I think it should work as long as you can get PICT data of the clipboard.
On 2. juli 2010, at 23.51, Matthew Strange wrote:
> At Fri, 02 Jul 2010 21:36:00 +1000, Shane Stanley wrote:
>
>> (I just went to do some testing and discovered that when I try to open a
>> PICT in Preview.app I get a message that the PICT file format is not
>> supported in 64-bit mode. So that talk of its being deprecated is true.)
>
> All the more pressure for me to get these PICTs out to files so they can be converted to something else!
>
> Actually, I solved my immediate problem with GraphicConverter -- that has a nice command for making a picture from clipboard data, which can then be saved in whatever format is preferred. My original hope was to use Image Events to do the conversion and avoid requiring the end users to purchase extra software. The rest of this is pure academic pursuit.
>
>> Anyway, this seems to work OK in 10.6:
>>
>> set x to the clipboard as picture -- get PICT data
>> set fileRef to (open for access file ((path to desktop as text) &
>> "Test.pict") with write permission)
>> set eof fileRef to 0
>> repeat 512 times
>> write "a" to fileRef
>> end repeat
>> write x to fileRef starting at 513
>> close access fileRef
>>
>> It doesn't matter what's written to the first 512 bytes, it seems.
>
>
> The reason I suggested ascii character 0 (more on that in a moment) is that, in my experiments, the OS X Finder grabs the dimensions out of the header for display (if you have the "show item info" option turned on). I initially wrote "PICTPICT..." into the header, and Finder reported the PICT as having dimensions of 17,134 x 17,134 (give or take a pixel). Writing ASCII 0 in there keeps the OS from showing incorrect info.
>
> (This is why it would be nice to be able to read the bytes in the data -- you could then learn the dimensions of the image and write the correct info into the header. But I digress.)
>
> Also, two folks kindly contacted me off-list to privately point out some foolishness on my part.
>
> 1: (ASCII character 0) is deprecated. I should have written (character id 0) so it would work in 10.4 and later. But I should point out that, in OS X 10.4.11 at least, writing "character id 0" into the file results in some unknown text appearing in there. (dle2....obj ...D....) That's probably a Tiger bug. And that makes the Finder info report the image as 17,408x1024 which is the calculated value of the '...D....' bit noted above. (That's bytes 18-25, for those who care.)
>
> 2: In my previous reply I suggested writing this into the first 512 bytes:
>> write "PICT" to myFile starting at 0
>> repeat 498 times
>> write (ASCII character 0) to myFile
>> end repeat
>
>
> Hmmm... 4 bytes + 498 bytes = 502... leaving me a bit shy of the required 512 bytes. Folding those two corrections together, it should read:
>
> write "PICT" to myFile starting at 0
> repeat 508 times
> write (character id 0) to myFile
> end repeat
>
> Hope this helps,
> Matt Strange
> --
> Light travels faster than sound. This must be why some people appear bright until you hear them speak.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
Best regards
Tommy Bollman
--------------------------------------------------------------------------------------------------
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review
and be implemented it wasn't worth doing.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden