OSDN Git Service

* change writting.
[modchxj/mod_chxj.git] / src / chxj_img_conv.c
1 /*
2  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
3  * Copyright (C) 2005 Atsushi Konno All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "mod_chxj.h"
18
19
20 char* 
21 chxj_img_conv(
22   request_rec* r, device_table* spec, const char* s)
23 {
24   char* dst;
25
26   dst = apr_pstrdup(r->pool, s);
27
28   if (spec) {
29     switch (spec->color) {
30     case 2       : dst = apr_pstrcat(r->pool, dst,".10", NULL); break;
31     case 4       : dst = apr_pstrcat(r->pool, dst,".20", NULL); break;
32     case 256     : dst = apr_pstrcat(r->pool, dst,".30", NULL); break;
33     case 4096    : dst = apr_pstrcat(r->pool, dst,".40", NULL); break;
34     case 65536   : dst = apr_pstrcat(r->pool, dst,".50", NULL); break;
35     case 262144  : dst = apr_pstrcat(r->pool, dst,".60", NULL); break;
36     case 15680000: dst = apr_pstrcat(r->pool, dst,".70", NULL); break;
37     default:       dst = apr_pstrcat(r->pool, dst,".30", NULL); break;
38     }
39
40     if (spec->available_jpeg != 0)
41       return apr_pstrcat(r->pool, dst,".jpg", NULL);
42
43     if (spec->available_png != 0)
44       return apr_pstrcat(r->pool, dst,".png", NULL);
45
46     if (spec->available_gif != 0)
47       return apr_pstrcat(r->pool, dst, ".gif", NULL);
48
49     if (spec->available_bmp4 != 0 || spec->available_bmp2 != 0)
50       return apr_pstrcat(r->pool, dst, ".bmp", NULL);
51   }
52
53   return dst;
54 }