0Syntax10.Scn.Fnt ZParcElemsAllocSyntax14m.Scn.FntSyntax12.Scn.Fnt InfoElemsAllocXSyntax10.Scn.FntStampElemsAlloc2002-Aug-14!"Title": Pictures.Text "Author": Christoph Steindl (CS), Markus Hof (MaH) "Abstract": Pictures.Text, short description of the modules Pictures, PElems, GIF "Keywords": pictures, graphics, text elements "Version": 1.0 "From": 25.06.96 09:07:13 "Until":  "Changes": no changes "Hints":  ZStyleElemsAlloc Normal Syntax12i.Scn.Fnt Syntax12b.Scn.Fnt%       '  %/P2D L^ / 3 J > K B<SC/: 8 + 8 =2 E12<    8: Zr  FirstIndent1RdKeplerElemsAllocKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FbRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F a/ %"  Y 'RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FPRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F#RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F , RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F )#(RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F VRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F$  RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F$ -RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FkRRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F'>RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F GZRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F(RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F! RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F- ~RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F'.RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F)  : RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F,%  RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F3RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F36 RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F5_RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F9_RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FC8RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F'RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F7 +RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F & X -RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FFKRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F9#$/J z 1  hRdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)FB8 Z  Z Normal Z 5& 3  Zr  FirstIndent1 RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F:RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F _RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F ORdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F& Z NormalM Z  Zr  FirstIndent1 RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F &$  Z NormalZ Z  Zr  FirstIndent1 RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F +$   Z Normalj Z   Zr  FirstIndent1 RdKeplerGraphsGraphDescKeplerGraphsStarDesc~~~Kepler8FilledCircleDescKeplerFramesCaptionDesc Syntax10.Scn.Fnt Syntax10.Scn.FntE)F<#: Z NormalSyntax8.Scn.FntP4Pictures, Picture Elements C. Steindl and M. Hof, 25 Jun 96  The module Pictures provides the means to displaying pictures of various formats on screen and for printing them. As of now there are implementations for Oberon for Windows and Oberon for PowerMac. Pictures may be freely interchanged between these platforms. Pictures may contain different numbers of colours. They may be indexed with a palette having 2, 16 or 256 entries, or true color pictures with 16, 24 or 32 bits per pixel. We support pictures of all those kinds. DEFINITION Pictures; IMPORT Display, Files; CONST done = 0; error = 2; needData = 1; TYPE LoadInfo = POINTER TO LoadInfoDesc; LoadInfoDesc = RECORD res: INTEGER; usedBytes: LONGINT; picture: Picture; PROCEDURE (li: LoadInfo) Completed; PROCEDURE (li: LoadInfo) Do; END; Picture = POINTER TO PictureDesc; PictureDesc = RECORD width-, height-, depth-: INTEGER; PROCEDURE (p: Picture) Copy (VAR res: INTEGER); PROCEDURE (p: Picture) CopyBlock (dP: Picture; sx, sy, w, h, dx, dy, mode: INTEGER); PROCEDURE (p: Picture) Draw (x, y, mode: INTEGER); PROCEDURE (p: Picture) DrawC (f: Display.Frame; x, y, mode: INTEGER); PROCEDURE (p: Picture) DrawStretched (sx, sy, sw, sh, dx, dy, dw, dh, mode: INTEGER); PROCEDURE (p: Picture) DrawStretchedC (f: Display.Frame; sx, sy, sw, sh, dx, dy, dw, dh, mode: INTEGER); PROCEDURE (p: Picture) GetColorIdx (VAR col: INTEGER); PROCEDURE (p: Picture) GetColorRGB (VAR r, g, b: INTEGER); PROCEDURE (p: Picture) GetPalette (col: INTEGER; VAR red, green, blue: INTEGER); PROCEDURE (p: Picture) GetPixelIdx (x, y: INTEGER; VAR col: INTEGER); PROCEDURE (p: Picture) GetPixelRGB (x, y: INTEGER; VAR red, green, blue: INTEGER); PROCEDURE (p: Picture) GetScanLine (VAR data: ARRAY OF CHAR; y: INTEGER); PROCEDURE (p: Picture) Init (width, height, depth: INTEGER); PROCEDURE (p: Picture) Text (s: ARRAY OF CHAR; x, y, mode: INTEGER; f: Fonts.Font); PROCEDURE (p: Picture) Load (VAR r: Files.Rider; VAR res: INTEGER); PROCEDURE (p: Picture) Paste (VAR res: INTEGER); PROCEDURE (p: Picture) Print (x, y, dw, dh, mode: INTEGER); PROCEDURE (p: Picture) ReplConst (x, y, w, h, mode: INTEGER); PROCEDURE (p: Picture) SetColorIdx (col: INTEGER); PROCEDURE (p: Picture) SetColorRGB (red, green, blue: INTEGER); PROCEDURE (p: Picture) SetPalette (col, red, green, blue: INTEGER); PROCEDURE (p: Picture) SetPixel (x, y, mode: INTEGER); PROCEDURE (p: Picture) SetScanLine (VAR data: ARRAY OF CHAR; y, h: INTEGER); PROCEDURE (p: Picture) Store (VAR r: Files.Rider); PROCEDURE (p: Picture) Update (new: Picture; x, y, w, h: INTEGER); END ; Loader = PROCEDURE (file: Files.File; pos: LONGINT): LoadInfo; UpdateMsg = RECORD (Display.FrameMsg) p, new: Picture; x, y, w, h: INTEGER END ; PROCEDURE Load (file: Files.File; pos: LONGINT): LoadInfo; PROCEDURE RegisterFormat (loader: Loader); VAR dx, dy: INTEGER); END Pictures. Types  LoadInfo contains information about the loading state of a picture. Such a pointer is received by calling Load.  Picture is an abstract data type representing a bitmap with a given width, height, and colour depth. Valid colour depths are 1, 4, 8, 16, 24, and 32.  An UpdateMsg indicates a change within the rectangle (x, y, w, h) in the picture denoted in the record field p. IF new # NIL, the text element that displays picture p shall replace picture p by picture new and perform the update with picture new. The programmer may broadcast an UpdateMsg by calling Update (see below). Pictures does not generate update messages on its own, i.e. the operations SetPixel, ReplConst and CopyBlock modify the picture without sending a notification. It is the responsibility of their caller to indicate an update by either calling Update or by broadcasting an update message.  Loader is a procedure type used by newly registered formats. A registered loader receives the file and position of a picture and has to decide wether it knows this format or not. Accordingly it has to return either a valid LoadInfo structure or NIL. Operations  p.Init(width, height, depth) initializes the internal data structures of the picture and allocates memory for a bitmap of the specified width, height and colour depth. Valid values for depth are 1, 4, 8, 16, 24, and 32. If the operation is not successful, the components width, height, and depth of the picture p are set to 0.  p.Load(r, res) loads the picture from rider r into the picture p. If it has been read successfully res is set to 0, otherwise it has a value # 0. The read file format is either the standard Windows bitmap format (BMP) or the OS/2 bitmap format. The original colour depth of the picture is used while showing the picture. Pictures using more colours than are available on screen, are dithered automatically in order to obtain satisfying results. Run-length encoded Windows bitmap pictures cannot be loaded directly. Those pictures can be converted with Conversions.RLEToBMP.  p.Store(r) stores the picture p to the rider r. If the picture has not been edited (i.e., SetPixel, ReplConst, and CopyBlock have not been used to modify the picture), the file is stored as it has been loaded. Otherwise the picture is stored in the standard Windows bitmap format (BMP) with the appropriate colour depth (1, 4, 8, 16, 24, or 32) without run-length encoding.  p.Paste(res) copies a picture from the clipboard into p. When the operation is successful res is set to 0. Under Windows the command Clipboard.Snapshot can be used to take a snapshot of the marked viewer (mark must be visible), or of the whole Oberon screen and put it into the clipboard. Clipboard.Snapshot with the parameter drag (i.e. Clipboard.Snapshot drag) enters the dragging mode where you can select an arbitrary screen region as a snapshot with the mouse. On the other hand, you can insert bitmaps into the clipboard from outside of Oberon (i.e., by other applications).  p.Copy(res) copies a picture to the clipboard. When the operation is successful res is set to 0.  p.SetPalette(col, red, green, blue) sets the palette entry col of the picture p to the values red, green and blue. SetPalette may only be called for pictures that use a palette to display their colours (colour depth <= 8). For pictures with more colours the behaviour is not defined.  p.GetPalette(col, red, green, blue) gets the palette entry col of the picture p. GetPalette must not be called for true colour pictures (p.depth > 8).  p.SetColorIdx(col) sets the current drawing colour to the colour specified by the palette entry col. For true colour pictures SetColor sets the current drawing colour to the colour also returned by Display.GetColor.  p.GetColorIdx(col) returns the current painting color for p. May only be called for palette pictures, i.e. p.depth <= 8.  p.SetColorRGB(red, green, blue) sets the current drawing colour to the colour specified by the triple (red, green, blue). For indexed pictures (p.depth <= 8), the colour is looked up in the palette of the picture using a best match strategy.  p.GetColorRGB(red, green, blue) returns the current painting color for p.  p.SetPixel(x, y, mode) draws a pixel at the position x, y in the current drawing colour of p. The mode can be either Display.replace, Display.paint, or Display.invert.  p.GetPixelIdx(x, y, col) returns the colour of the picture at positon x, y. col is the entry of the palette of the picture used to display the specified pixel (must not be called for true colour pictures).  p.GetPixelRGB(x, y, red, green, blue) returns the rgb values of the pixel at positon x, y.  p.ReplConst(x, y, w, h, mode) draws a filled rectangle at the position x, y with width w and height h using the current drawing colour. The mode can be either Display.replace, Display.paint, or Display.invert.  p.CopyBlock(dP, sx, sy, w, h, dx, dy, mode) copies the rectangle at the position sx, sy with width w and h of the picture p to the destination picture dP at the position dx, dy. The mode can be either Display.replace, Display.paint, or Display.invert.  p.Draw(x, y, mode) draws the picture at the Oberon screen coordinates x, y. The mode can be either Display.replace, Display.paint, or Display.invert.  p.DrawC(f, x, y, mode) draws the picture at the Oberon screen coordinates x, y. Clipping is performed at the boundaries of the frame f. The mode can be either Display.replace, Display.paint, or Display.invert.  p.DrawStreched(sx, sy, sw, sh, dx, dy, dw, dh, mode) draws the the rectangle (sx, sy) - (sx+w, sy+h) of picture p at the Oberon screen coordinates dx, dy. The picture is streched automatically to fit into the destination rectangle (dx, dy) - (dx+dw, dy+dh). The mode can be either Display.replace, Display.paint, or Display.invert.  p.DrawStrechedC(f, sx, sy, sw, sh, dx, dy, dw, dh, mode) draws the the rectangle (sx, sy) - (sx+w, sy+h) of picture p at the Oberon screen coordinates dx, dy. The picture is streched automatically to fit into the destination rectangle (dx, dy) - (dx+dw, dy+dh). Clipping is performed at the boundaries of the frame f. The mode can be either Display.replace, Display.paint, or Display.invert.  p.SetScanLine(data, y, h) inserts a line of pixels (data holding color indices or RGB-values) into the picture at position y. The line is duplicated to build a a block with height h. When loading pictures from the net, this technique is used to show previews of the loaded picture (which is broken up into scanlines).  p.SetScanLine(data, y) retrieves a line of pixels at position y.  p.Print(x, y, dw, dh, mode) prints the picture at the absolute printer coordinates x, y with the destination width dw and height dh. (Windows: The mode is currently ignored).  p.Update(new, x, y, w, h) broadcasts an UpdateMsg indicating a change of picture p. IF new # NIL, the picture p shall be replaced by picture new. Only the region x, y, w, h is updated. Updates are not sent implicitly whenever a picture changes (e.g. through a SetPixel, ReplConst, or CopyBlock), as this might result in heavy redrawings.  p.Text (str, x, y, mode, font) inserts a piece of text with the given font and mode at the position (x, y) into the picture p. The lower left corner of the bounding box of the text is at the position (x, y).  li := Load (file, pos) tries to find a loader for the picture format in the specified file. If a loader is found (only windows bitmap loader preinstalled) a valid LoaderInfo is returned, otherwise NIL.  li.Do is called by the client to start the next loading step. li.Do has to ensure, that all fields of li have valid values upon its return. li.res indicates wether the conversion has finished (done), wether an error occured (error) or wether the conversion is not yet done and Do has to be called again (needData). li.usedBytes indicates how many bytes are already used up by the conversion. The total number of bytes has to be known by the client. li.picture is the picture resulting from the conversion. If li.picture is not NIL, li.Do has to use this picture as the destination of the conversion. Otherwise it may allocate a new picture.  RegisterFormat (loader) registers a new picture format (e.g. GIF). Called from a client, Load scans all registered formats for an accepting loader. Picture Elements Picture elements are text elements that can be used to insert pictures into text documents. Picture elements react on update messages by redrawing the entire picture. DEFINITION PElems; IMPORT Texts, Pictures, Display, Files; TYPE Elem = POINTER TO ElemDesc; ElemDesc = RECORD (Texts.ElemDesc) pic: Pictures.Picture END; PROCEDURE Alloc; PROCEDURE Handler (e: Texts.Elem; VAR m: Texts.ElemMsg); PROCEDURE Insert; PROCEDURE Paste; END PElems.  Operations  PElems.Insert name loads the picture from file name and inserts a new picture element at the caret position.  PElems.Paste copies the picture from the clipboard and inserts a new picture element at the caret position.  PElems.Alloc is the allocating command used when loading texts containing picture elements.  PElems.Handler is the handler for picture elements. GIF GIF decodes gif files and converts them to Oberon bitmaps (windows bitmaps). DEFINITION GIF; PROCEDURE Install; END GIF.  Operations  GIF.Install installs the gif converter in module Pictures. To load a gif file one should use Pictures.Load. XBM XBM decodes x-windows bitmap files and converts them to Oberon bitmaps (windows bitmaps). DEFINITION XBM; PROCEDURE Install; END XBM.  Operations  XBM.Install installs the x-bitmap converter in module Pictures. To load a x-bitmap one should use Pictures.Load. Conversions (Windows only) This module provides commands for converting pictures from various formats into standard Windows bitmaps. DEFINITION Conversions; PROCEDURE RLEToBMP; END Conversions.  Operations  RLEToBMP name newName converts the run-length encoded picture stored in the file name to a standard Windows bitmap. If a newName is specified, the converted picture is stored in the file newName, otherwise the file name is overwritten. AsciiCoder.CodeFiles % Pictures.Text BMPBase.Mod Pictures.Mod PElems.Mod Conversions.Mod ~ Folds.Compile BMPBase.Mod/s Pictures.Mod/s PElems.Mod/s Conversions.Mod/s ~