[Newbies] FW: Bitmap-Arrays too large for "contents"

Bert Freudenberg bert at freudenbergs.de
Wed Dec 23 09:30:45 UTC 2009


On 23.12.2009, at 03:03, Hans Gruber wrote:
> 
>> Hi Squeak-Fans!
>> 
>> I am new in programming squeak an I have the following problem:
>> 
>> I want to integrate bitmap-arrays in my project for the images used in it. To get the elements for my bit-map array I used:
>> 
>> | image stream |
>> image := ColorForm fromFileNamed:
>> '/path/to/picture/icon.gif'.
>> stream := WriteStream with: String new.
>> image storeOn: stream.
>> stream contents.
>> 
>> By inspecting contents I can copy & paste its elements to the corresponding methods for the image. The Problem now is, that some of my images generate more bitmap-code elements than "contents" can display. Do you have an Idea how may copy&paste all the elements of the Stream!? I tried Seaside WAFileLibrary and pasted the generated methods, but WAFileLibrary returns byte-arrays, which can't be interpretet within the squeak form of *Morph.
>> 
>> So does anybody of you have an Idea and may help me?
>> 
>> Thanks,
>> Regards.
>> 
> 
>> Your last line could become
>> 
>> 	Clipboard clipboardText: stream contents
>> 
>> However, the canonical way would be to simply generate the method rather than doing it manually. Generating a method can be as simple as
>> 
>> 	MyClass compile: 'myMethod ^42'
>> 
>> See, for example, MenuIcons>>importIconNamed:.
>> 
>> - Bert -
> 
> Hi Bert & Squeak Community,
> thanks for your cool tip. I'll try to generate the methods via "class compile".
> I've tested it and a new problem came up. I did it the same way MenuIcons>>importIconNamed is implemented.
> The problem now is, that there comes up a error message ("MessageNotUnterstood(Metaclass)>>category") although I've inserted classfied : 'generated methods' and the category is already created and exists.
> 
> Here the code snippet:
> 
> generateMethodsForJPG: aString
> | writer image stream |
> 	writer := JPEGReadWriter on: (FileStream fileNamed: aString, '.jpg').
> 	[ image := writer nextImage]	
> 		ensure: [writer close].
> 	stream := ReadWriteStream on: (String new).
> 	stream nextPutAll: aString ; cr.
> 	stream nextPutAll: (self methodStart: aString).
> 	image storeOn: stream.
> 	stream nextPutAll: self methodEnd.
> 	MyGraphicLibrary class compile: stream contents classified: 'generated methods' notifying: nil.
> 	^ stream contents
> 
> MyGraphicLibrary is a subclass of Object.
> The error comes up at "compile:[...]". Everything before that works fine. Form is created etc. Simply the compilation does not work.

Should work fine. Please post the full SqueakDebug.log

- Bert -




More information about the Beginners mailing list