Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <draw.h>
4
#include <memdraw.h>
5
#include <bio.h>
6
#include "imagefile.h"
7
 
8
/* Separate colors, if not a grey scale or bitmap, into one byte per color per pixel, no alpha or X */
9
/* Result is GREY[1248] or RGB24 */
10
 
11
static
12
int
13
notrans(ulong chan)
14
{
15
	switch(chan){
16
	case GREY1:
17
	case GREY2:
18
	case GREY4:
19
	case GREY8:
20
	case RGB24:
21
		return 1;
22
	}
23
	return 0;
24
}
25
 
26
Image*
27
multichan(Image *i)
28
{
29
	Image *ni;
30
 
31
	if(notrans(i->chan))
32
		return i;
33
 
34
	ni = allocimage(display, i->r, RGB24, 0, DNofill);
35
	if(ni == nil)
36
		return ni;
37
	draw(ni, ni->r, i, nil, i->r.min);
38
	return ni;
39
}
40
 
41
Memimage*
42
memmultichan(Memimage *i)
43
{
44
	Memimage *ni;
45
 
46
	if(notrans(i->chan))
47
		return i;
48
 
49
	ni = allocmemimage(i->r, RGB24);
50
	if(ni == nil)
51
		return ni;
52
	memimagedraw(ni, ni->r, i, i->r.min, nil, i->r.min, S);
53
	return ni;
54
}