J008 Adding binary samples

Content outdated

We are in the process of migrating all content to impulse version 2.0.

Binary signals are built of byte arrays. In this example we use binary signals to display images.

Binary Signals

In general, the binary data can be anything. If BINARY_CONTENT_IMAGE is selected, the binary data shall be in form of packed images supported by the SWT ImageLoader("WinBMP", "WinBMP", "GIF", "WinICO", "JPEG", "PNG", "TIFF", "OS2BMP") .


This is the interface:

public interface IBinarySamplesWriter extends ISamplesWriter{
    boolean write(long units, boolean conflict, byte[] value);    

The parameters have the following meaning:

No of domain units (e.g. ns)
Define this sample as a conflict one.
An array of byte


Now take a look at these examples (out of de.toem.impulse.serializer.ExampleBinaryReaderReader):

        Scope signals = addScope(null, "Signals");
        Signal image1 = addSignal(signals, "Image", "An image signal", 
                ProcessType.Discrete, SignalType.Binary, new SignalDescriptor(

To create a binary signal, you need to give the signal type SignalType.Binary and a signal descriptor with its content description (STRUCT_BINARY_IMAGE,..).

Writing an image signal

Here an example that writes png images from a a gif sequence.

        // images
        IBinarySamplesWriter imageWriter = (IBinarySamplesWriter) getWriter(image1);
        try {
            ImageData[] imageData = new ImageLoader()
                ExtensionToolkit.PLUGIN_ID, "input.gif"));
            for (ImageData data : imageData) {
                ImageLoader loader = new ImageLoader();
                loader.data = new ImageData[] { data };
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                loader.save(out, SWT.IMAGE_PNG);
                imageWriter.write(t, false, out.toByteArray());
                t += 500;
        } catch (IOException e) {

technical software and tooling


Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.