OSDN Git Service

* Added test code of the <plaintext> tag for au HDML converter.
[modchxj/mod_chxj.git] / src / chxj_img_conv.c
1 /*
2  * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. 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, 
23   device_table* spec, 
24   const char*   s)
25 {
26   char* dst;
27
28   dst = apr_pstrdup(r->pool, s);
29
30   if (spec) {
31     switch (spec->color) {
32     case 2       : dst = apr_pstrcat(r->pool, dst,".10", NULL); break;
33     case 4       : dst = apr_pstrcat(r->pool, dst,".20", NULL); break;
34     case 256     : dst = apr_pstrcat(r->pool, dst,".30", NULL); break;
35     case 4096    : dst = apr_pstrcat(r->pool, dst,".40", NULL); break;
36     case 65536   : dst = apr_pstrcat(r->pool, dst,".50", NULL); break;
37     case 262144  : dst = apr_pstrcat(r->pool, dst,".60", NULL); break;
38     case 15680000: dst = apr_pstrcat(r->pool, dst,".70", NULL); break;
39     default:       dst = apr_pstrcat(r->pool, dst,".30", NULL); break;
40     }
41
42     if (spec->available_jpeg)
43       return apr_pstrcat(r->pool, dst,".jpg", NULL);
44
45     if (spec->available_png)
46       return apr_pstrcat(r->pool, dst,".png", NULL);
47
48     if (spec->available_gif)
49       return apr_pstrcat(r->pool, dst, ".gif", NULL);
50
51     if (spec->available_bmp4 || spec->available_bmp2)
52       return apr_pstrcat(r->pool, dst, ".bmp", NULL);
53   }
54
55   return dst;
56 }