B4A

Mostrando las entradas con la etiqueta Graphics. Mostrar todas las entradas
Mostrando las entradas con la etiqueta Graphics. Mostrar todas las entradas

domingo, noviembre 30, 2008

More tips to get graphics inside the image

Some time ago I already talked about this topic. But what happens when the graphics is a bit big and the usual #printString, #fullPrintString, #longPrintString only show the first 5000 chars and ends with "etc..."

We talked about this topic with Jecel on the Squeak IRC and also with Nico Petton, who suggested this way to avoid the "etc..."

The trick is having the string on a text file, and then copy from them. The code that make the job is the following:

jueves, septiembre 11, 2008

How to change the Aida/Web banner

I'm in the way of use and learn Aida/Web and Scribo and I'm starting using Scribo as wiki.

In this way I need to learn a lot of things, and I will post here some small "how to's" of things that may be useful to other people in the same way as me.

After install all the needed packages in a Squeak image, and having Scribo running, the first thing may be desirable may be to change the Aida banner for an own one.

Then, you need to "save as" such banner and generate a new image of the same size that which you saved, decorate it with your own graphics and then do the following:

1. Evaluate in a workspace on your Aida image:

WebStyle new importImage: 'aidabannergif' from: 'aidabannergif.gif'.

were aidabanner.gif is the name of the graphics file on your image directory and #aidabannergif the name of the method to be created on the WebStyle class under the category imgs.

2. Replace the content of the method #aidaBannerGif of class DefaultWebStyle with the content of the recent created in the step 1 and it's all.


To end, you should delete the method #aidabannergif on class WebStyle to maintain your image as clean as possible.

Of course, this is the quick and dirty method to have things as fast as possible, but the correct way should be create your own webstyle. Surely I will talk about this topic sooner or later.

jueves, junio 29, 2006

Algunos tips sobre manejo de gráficos en Squeak y Seaside

Una forma de mostrar gráficos (png, jpg) es leyéndolos desde el disco rígido, sin embargo, es mucho más cómodo incluirlos en algún método de nuestros objetos en forma de código fuente, de manera que los podamos tener disponibles cada vez que instalemos nuestro código en una nueva imagen.

La forma de hacerlo es la siguiente:

myMethod



x := Form fromFileNamed:'reload.png'.

xArray := x bits asArray.



^ ShoreForm

extent: 32@32

depth: 32

fromArray: xArray

offset: 0@0.


El código es muy simple y se explica por si mismo (en el ejemplo reemplazamos el logo de ShoreComponents por uno propio).

Como usamos la clase Form para esta tarea y la misma trabaja con imágenes de tipo gif, seguramente vamos a tener problemas de definición en los íconos que veamos desde Seaside, lo cual se arregla reemplazando el método asMIMEDocument de la clase Form, de la siguiente manera:

asMIMEDocument

| aStream rw |

aStream := RWBinaryOrTextStream on: String new.

rw := PNGReadWriter on: aStream.

rw nextPutImage: self.

rw close.

aStream reset.

^MIMEDocument contentType: 'image/png' content: aStream contents

Gracias a Diego por este último tip.