Hi,
I am trying to write a Photo Manager Application, to learn Morphic and
Squeak. So far I have created a custom Thumbnail morph
"LabeledThumbnail" that is capable of holding a form and a label:
First I create forms like that:
form := (ImageReadWriter
formFromFileNamed:'/home/felix/DCIM/101HPIMG/HPIM1625.JPG')
Thumbnails are then derived by (this is an instance method of
LabeledThumbnail, not sure about the >> notation):
LabeledThumbnail>>form: aForm
thumbnail ifNotNil: [ self removeMorph: thumbnail].
thumbnail _ Thumbnail new.
thumbnail maxWidth:150 minHeight:100.
thumbnail makeThumbnailFromForm: aForm.
self addMorph: thumbnail.
Now I created a new Class "ThumbnailBar", that displays a collection of
LabeledThumbnails:
ThumbnailBar class>>newFromPhotoCollection: aPhotoCollection
| tmp form |
tmp _ self new.
aPhotoCollection do: [ :entry |
form _ ImageReadWriter formFromFileNamed:
entry.
tmp addMorph: (LabeledThumbnail
newFromForm: form withLabel: entry) asMorph
].
^ tmp
PhotoCollection is a bare list of filenames.
Obviously this is not complete, I want to add scrollbars etc. However,
my current issue is speed. Doing a
col := PhotoCollection newFromDirectory: '/home/felix/DCIM'.
(ThumbnailBar newFromPhotoCollection: col) openInWorld
takes about way too long (minutes range) until the Thumbnail bar shows
up (there are about 200 hi-res jpegs in the collection).
I guess that the most time is spent loading and scaling the images, so
I'll probably cache the thumbs on disk. Another issue is easier and more
intresting to me: I like to reduce the number of Morph objects. E.G. my
"LabeledThumbnail" is a RectangleMorph that owns an ImageMorph and a
StringMorph. I want to get rid of the submorphs and write my own drawing
code. I have already seen how this is done, but am a little afraid of
the redrawing/updating stuff. E.g. this confuses me already:
ImageMorph>>image: anImage
self changed.
image := anImage depth = 1
ifTrue: [ColorForm mappingWhiteToTransparentFrom: anImage]
ifFalse: [anImage].
super extent: image extent
Intuitively the "changed" message should be send as the _last_
statement, not the first one. Can anyone explain?
Thanks,
Felix
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners