File: appImage.c

package info (click to toggle)
ted 2.11-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 11,064 kB
  • ctags: 13,935
  • sloc: ansic: 120,446; makefile: 7,469; sh: 253
file content (104 lines) | stat: -rw-r--r-- 2,713 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/************************************************************************/
/*  Scan, main module.							*/
/************************************************************************/

#   include	"appFrameConfig.h"

#   include	<stddef.h>
#   include	<stdio.h>
#   include	<stdlib.h>

#   include	"appImage.h"
#   include	<appFrame.h>

#   include	<appDebugon.h>

/************************************************************************/
/*									*/
/*  Clean an image structure.						*/
/*									*/
/************************************************************************/

void appCleanBitmapImage(	AppBitmapImage *	abi )
    {
    if  ( abi->abiBuffer )
	{
	free( abi->abiBuffer );
	abi->abiBuffer= (unsigned char *)0;
	}

    bmCleanDescription( &abi->abiBitmap );
    bmInitDescription( &abi->abiBitmap );
    }

void appInitBitmapImage(	AppBitmapImage *	abi )
    {
    bmInitDescription( &abi->abiBitmap );
    abi->abiBuffer= (unsigned char *)0;
    abi->abiFormat= -1;
    abi->abiFactor= 10;
    }

/************************************************************************/
/*									*/
/*  Make the list of bitmap FileExtensions that can be opened/saved.	*/
/*									*/
/************************************************************************/

int appImgMakeFileExtensions(	AppFileExtension **	pAfeList,
				int *			pAfeCount )
    {
    int			i;
    AppFileExtension *	afe;
    int			afeCount;

    BitmapFileFormat *	bff;
    BitmapFileType **	pbft;

    afeCount=  bmNumberOfFileTypes+ bmNumberOfFileFormats;
    afe= (AppFileExtension *)malloc( afeCount * sizeof(AppFileExtension) );
    if  ( ! afe )
	{ LXDEB(afeCount,afe); return -1;	}

    afeCount= 0;

    bff= bmFileFormats;
    for ( i= 0; i < bmNumberOfFileFormats; bff++, i++ )
	{
	unsigned	flags= APPFILE_IS_BASIC_TYPE;

	afe[afeCount].afeId= bff->bffId;
	afe[afeCount].afeFilter= bff->bffFileType->bftFileFilter;
	afe[afeCount].afeDescription= bff->bffDescription;
	afe[afeCount].afeExtension= bff->bffFileType->bftFileExtension;

	if  ( bff->bffFileType->bftRead )
	    { flags |= APPFILE_CAN_OPEN;	}
	if  ( bff->bffFileType->bftWrite )
	    { flags |= APPFILE_CAN_SAVE;	}

	afe[afeCount].afeUseFlags= flags;

	afeCount++;
	}

    pbft= bmFileTypes;
    for ( i= 0; i < bmNumberOfFileTypes; pbft++, i++ )
	{
	afe[afeCount].afeId= (*pbft)->bftTypeId;
	afe[afeCount].afeFilter= (*pbft)->bftFileFilter;
	afe[afeCount].afeDescription= (*pbft)->bftTypeDescription;
	afe[afeCount].afeExtension= (*pbft)->bftFileExtension;

	if  ( ! (*pbft)->bftRead )
	    { afe[afeCount].afeUseFlags= 0;			}
	else{ afe[afeCount].afeUseFlags= APPFILE_CAN_OPEN;	}

	afeCount++;
	}

    *pAfeList= afe;
    *pAfeCount= afeCount;

    return 0;
    }