. .

st4u

ST 4U 375: Reading Image Files in VA Smalltalk

April 26, 2013 13:41:31.171

Today's Smalltalk 4 You looks at reading inage files (such as JPG) into VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

images.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


It's pretty easy to read in image (graphic) files in VA Smalltalk (so long as they are in a supported format). Have a look at class CgImageFileFormat and its subclasses - each concrete subclass reads in a particular kind of file. For instance - to read a JPG, you can do one of two things:


file := CfsFileDescriptor open: 'thuum.jpg' oflag: ORDONLY.
image := format loadFromFileHandle: file atOffset: 0.
file close.
^image

| format image |
format := CgJPEGFileFormat new.
image := format loadFromFile: 'thuum.jpg'.
^image

Notice how we don't need to deal with opening/closing the file in the second example? That's because the framework handles those details. You don't need to worry about catching exceptions for unhanded formats or non-existent files, either - say you try this:


| format image |
format := CgJPEGFileFormat new.
image := format loadFromFile: 'someimage.jpg'.
^image

| format image |
format := CgJPEGFileFormat new.
image := format loadFromFile: 'someimage.png'.
^image

In the first case, the file does not exist - in the second, the format (PNG) is not supported. Either way, the VA code hands you back nil. So, whenever you read an image file, you'll want to check against nil. Finally, what do you get back?

You get an instance of CgDeviceIndependentImage.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

Enclosures:
[st4u375-iPhone.m4v ( Size: 1129163 )]

posted by James Robertson

 Share Tweet This

smalltalk

No Podcast This Weekend

April 28, 2013 12:57:05.417

I've had a cold for the last few days, so I was not able to record a podcast with Dave - we'll be back next weekend with new content for you though!

Tags:

posted by James Robertson

 Share Tweet This

st4u

ST 4U 376: Not Showing the Herald in ObjectStudio

April 29, 2013 10:47:10.011

Today's Smalltalk 4 You looks at the herald image that pops up when you start ObjectSTudio (or VisualWorks). More specifically, how to turn that off without changing your command line. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

herald

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: , ,

Enclosures:
[st4u376-iPhone.m4v ( Size: 1148771 )]

posted by James Robertson

 Share Tweet This

js4u

JS 4U 266: Adding a Weather Layer

April 30, 2013 11:08:21.658

Javascript 4 U

Today's Javascript 4 You looks at adding a weather layer to roadmap. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

weather layer

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[js4u266-iPhone.m4v ( Size: 600713 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 377: Seaside, Pharo, and JQuery

May 1, 2013 14:50:14.982

Today's Smalltalk 4 You is a longer video - Nick Ager reprising an ESUG presentation on developing mobile apps using Seaside, Pharo, and JQuery. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Pharo and Seaside

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: , , , ,

Enclosures:
[Pharo-Seaside-iPhone.m4v ( Size: 94277116 )]

posted by James Robertson

 Share Tweet This

weather

Glad I'm Remote This Week

May 1, 2013 22:05:07.294

It hit 70 today here in Columbia; Minneapolis, where I was last week, is still not getting spring:

Tags:

posted by James Robertson

 Share Tweet This

js4u

JS 4U 267: Styling Map Elements

May 2, 2013 9:50:20.189

Javascript 4 U

Today's Javascript 4 You looks at styling individual elements of a map. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

map styling

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Tags: ,

Enclosures:
[js4u267-iPhone.m4v ( Size: 1450452 )]

posted by James Robertson

 Share Tweet This

smalltalk

Gemstone is Independent Again

May 2, 2013 13:45:57.052

From James Foster:

Great news! The GemStone/S team is becoming an independent company after 3 years as part of VMware. The core engineering team, including me, along with Norm Green and Dan Ware, have formed GemTalk Systems. For more information, visit our company web site at http://gemtalksystems.com.

Tags:

posted by James Robertson

 Share Tweet This

st4u

ST 4U 378: Determining the Image File Format

May 3, 2013 3:27:52.716

Today's Smalltalk 4 You looks at figuring out which image reader to use on a given file you want to deal with. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Image Reading.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Last time we looked at reading images in from the file system into VA Smaltalk - and we noted that you need to line up the specific reader with the correct format. However, with a bit of glue code of your own, it's easy to determine which reader (if any) can read a given file, and select it. Try this on a JPG, for instance:


| file |
file := CfsFileDescriptor open: 'thuum.jpg' oflag: ORDONLY.
(CgPCXFileFormat formatMatchesFileHandle: file atOffset: 0)
    ifTrue: [Transcript cr; show: 'Format matches.']
    ifFalse: [Transcript cr; show: 'Format does not match.'].
file close.

You should see a negative in the Transcript. Now, try the same thing using the JPG reader:


| file |
file := CfsFileDescriptor open: 'thuum.jpg' oflag: ORDONLY.
(CgJPEGFileFormat formatMatchesFileHandle: file atOffset: 0)
    ifTrue: [Transcript cr; show: 'Format matches.']
    ifFalse: [Transcript cr; show: 'Format does not match.'].
file close.


And you'll see that it works. Given that, and a bit of glue code of your own, it would be simple to create a "find the right reader" class - and to then create readers for formats that are not already supported, and fit them into the existing framework.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

Enclosures:
[st4u378-iPhone.m4v ( Size: 1430136 )]

posted by James Robertson

 Share Tweet This