[clean-list] Two questions (Types and graphics)
John van Groningen
johnvg@cs.kun.nl
Tue, 9 Jan 2001 16:04:55 +0000
Jerzy Karczmarczuk wrote:
>...
>I defined a linear interpolation operator:
>
> linterp i0 i1 t
> | t<zero = i0
> | t>one = i1
> | otherwise = (one-t)*>i0 + t*>i1
>
>and I put it into the main module, in order to request from the compiler
>its type. You, guru folks do the same, I see it from the fact that
>plenty of your declaration and implementation modules have
>trailing, useless semicolons in type declarations...
>
>I got
>
> linterp :: (a b) (a b) b -> a b | * , - , < , one , zero b & *> a;
The compiler has derived an incorrect type. The context restriction +(a b)
is missing. It should be:
linterp :: (a b) (a b) b -> a b | * , - , < , one , zero b & *> a & + (a b);
>and using the marvelous lazy functional technique called cut-and-paste,
>I transferred linterp into my shared library.
>
>Then I recompiled the main module and its subsidiaries, and I got
>
>Type error [Veclib.icl,87,linterp]:
> "+" requested instance of the form (m a1 .. ak) is impossible
This is correct, because + (a b) is missing.
Unfortunately such contexts are not supported by Clean 1.3.3.
>...
>
>A few other questions.
>
>How to *READ A PIXEL* from a Picture?
>Even simpler: how to read a pixel value from a bitmap?
This is not implemented in ObjectIO.
>I remember the answers of Peter Achten some months ago. Picture is
>an output-only structure etc. Not sure, what a pixel is, etc. do
>everything yourself. We would like to, not our priority, etc.
>Frankly, not very promising answers.
>
>I'll tell you what I tried concerning bitmaps. First I moved to a
>Windows (NT) machine. Then, I opened the file using openbitmap,
>and recovered the OsBitmap structure.
>
>I got several pieces of data, for example the size, say, 284*281
>of my BMP picture. And the {#Char} BitmapContent as well. But it
>is not directly usable.
>
>I know, the data in a BMP and the pixel array are different things.
>I looked into pictCCall_12.icl, but from your inline codes one
>cannot learn anything. HDC is just an integer, the access routines
>are opaque. What can I do with the bitmapHandle? Where is the
>palette? (Suppose I want to do some colour cycling.)
The inline codes are calls to functions written in C. The code of the
functions using bitmaps can be found in the file 'cpicture_12.c'
in the directory 'OS Windows/Windows_C_12' of Object IO 1.2.1.
>I know (more or less) the BMP file format. Shall I process the
>BMP contents by hand? It would be utterly silly, Windows did it
>for me. I checked as far as I could the Windows programming sections
>in IO lib, nothing found.
>
>I wonder whether you have ever documented this low-level side of
>Clean IO programming in order to ENABLE OTHERS TO DO SOME WORK?
As far as I know this has not been documented.
>...
>Why don't you use some DLLs instead of your inline codes? It
>might then be easier to make it more portable.
>...
The inline codes are calls to C functions, putting this C code in a DLL instead
of an object file doesn't make it easier to change this code.
Regards,
John van Groningen