o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files o moved some files aroundulab-next
parent
3cedfae76a
commit
1123323fda
Binary file not shown.
@ -0,0 +1,59 @@
|
||||
|
||||
# detached brackets
|
||||
--style=allman
|
||||
|
||||
# 4 spaces, no tabs
|
||||
--indent=spaces=4
|
||||
|
||||
# for C++ files only
|
||||
--indent-classes
|
||||
|
||||
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block.
|
||||
# The entire case block is indented.
|
||||
--indent-switches
|
||||
|
||||
# Add extra indentation to namespace blocks. This option has no effect on Java files.
|
||||
--indent-namespaces
|
||||
|
||||
# Converts tabs into spaces in the non-indentation part of the line.
|
||||
--convert-tabs
|
||||
|
||||
# requires --convert-tabs to work properly
|
||||
--indent-preprocessor
|
||||
|
||||
--indent-col1-comments
|
||||
|
||||
--min-conditional-indent=2
|
||||
|
||||
--max-instatement-indent=40
|
||||
|
||||
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
|
||||
--break-blocks
|
||||
|
||||
# Insert space padding around operators.
|
||||
--pad-oper
|
||||
|
||||
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
|
||||
--pad-header
|
||||
|
||||
|
||||
# Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
|
||||
--add-brackets
|
||||
|
||||
--align-pointer=name
|
||||
|
||||
# Do not retain a backup of the original file. The original file is purged after it is formatted.
|
||||
--suffix=none
|
||||
|
||||
# For each directory in the command line, process all subdirectories recursively.
|
||||
--recursive
|
||||
|
||||
# Preserve the original file's date and time modified.
|
||||
--preserve-date
|
||||
|
||||
# Formatted files display mode. Display only the files that have been formatted.
|
||||
# Do not display files that are unchanged.
|
||||
--formatted
|
||||
|
||||
--lineend=linux
|
||||
|
@ -1,217 +1,226 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
simple list
|
||||
*/
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* simple list
|
||||
*/
|
||||
|
||||
#include "arch.h"
|
||||
#include "os_calls.h"
|
||||
#include "list.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
struct list* APP_CC
|
||||
struct list *APP_CC
|
||||
list_create(void)
|
||||
{
|
||||
struct list* self;
|
||||
struct list *self;
|
||||
|
||||
self = (struct list*)g_malloc(sizeof(struct list), 1);
|
||||
self->grow_by = 10;
|
||||
self->alloc_size = 10;
|
||||
self->items = (tbus*)g_malloc(sizeof(tbus) * 10, 1);
|
||||
return self;
|
||||
self = (struct list *)g_malloc(sizeof(struct list), 1);
|
||||
self->grow_by = 10;
|
||||
self->alloc_size = 10;
|
||||
self->items = (tbus *)g_malloc(sizeof(tbus) * 10, 1);
|
||||
return self;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_delete(struct list* self)
|
||||
list_delete(struct list *self)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (self->auto_free)
|
||||
{
|
||||
for (i = 0; i < self->count; i++)
|
||||
int i;
|
||||
|
||||
if (self == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->auto_free)
|
||||
{
|
||||
g_free((void*)self->items[i]);
|
||||
self->items[i] = 0;
|
||||
for (i = 0; i < self->count; i++)
|
||||
{
|
||||
g_free((void *)self->items[i]);
|
||||
self->items[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free(self->items);
|
||||
g_free(self);
|
||||
|
||||
g_free(self->items);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_add_item(struct list* self, tbus item)
|
||||
list_add_item(struct list *self, tbus item)
|
||||
{
|
||||
tbus* p;
|
||||
int i;
|
||||
|
||||
if (self->count >= self->alloc_size)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
self->alloc_size += self->grow_by;
|
||||
p = (tbus*)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
g_memcpy(p, self->items, sizeof(tbus) * i);
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
self->items[self->count] = item;
|
||||
self->count++;
|
||||
tbus *p;
|
||||
int i;
|
||||
|
||||
if (self->count >= self->alloc_size)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
self->alloc_size += self->grow_by;
|
||||
p = (tbus *)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
g_memcpy(p, self->items, sizeof(tbus) * i);
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
|
||||
self->items[self->count] = item;
|
||||
self->count++;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
tbus APP_CC
|
||||
list_get_item(struct list* self, int index)
|
||||
list_get_item(struct list *self, int index)
|
||||
{
|
||||
if (index < 0 || index >= self->count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return self->items[index];
|
||||
if (index < 0 || index >= self->count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return self->items[index];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_clear(struct list* self)
|
||||
list_clear(struct list *self)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (self->auto_free)
|
||||
{
|
||||
for (i = 0; i < self->count; i++)
|
||||
if (self->auto_free)
|
||||
{
|
||||
g_free((void*)self->items[i]);
|
||||
self->items[i] = 0;
|
||||
for (i = 0; i < self->count; i++)
|
||||
{
|
||||
g_free((void *)self->items[i]);
|
||||
self->items[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free(self->items);
|
||||
self->count = 0;
|
||||
self->grow_by = 10;
|
||||
self->alloc_size = 10;
|
||||
self->items = (tbus*)g_malloc(sizeof(tbus) * 10, 1);
|
||||
|
||||
g_free(self->items);
|
||||
self->count = 0;
|
||||
self->grow_by = 10;
|
||||
self->alloc_size = 10;
|
||||
self->items = (tbus *)g_malloc(sizeof(tbus) * 10, 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
list_index_of(struct list* self, tbus item)
|
||||
list_index_of(struct list *self, tbus item)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < self->count; i++)
|
||||
{
|
||||
if (self->items[i] == item)
|
||||
for (i = 0; i < self->count; i++)
|
||||
{
|
||||
return i;
|
||||
if (self->items[i] == item)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_remove_item(struct list* self, int index)
|
||||
list_remove_item(struct list *self, int index)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (index >= 0 && index < self->count)
|
||||
{
|
||||
if (self->auto_free)
|
||||
if (index >= 0 && index < self->count)
|
||||
{
|
||||
g_free((void*)self->items[index]);
|
||||
self->items[index] = 0;
|
||||
if (self->auto_free)
|
||||
{
|
||||
g_free((void *)self->items[index]);
|
||||
self->items[index] = 0;
|
||||
}
|
||||
|
||||
for (i = index; i < (self->count - 1); i++)
|
||||
{
|
||||
self->items[i] = self->items[i + 1];
|
||||
}
|
||||
|
||||
self->count--;
|
||||
}
|
||||
for (i = index; i < (self->count - 1); i++)
|
||||
{
|
||||
self->items[i] = self->items[i + 1];
|
||||
}
|
||||
self->count--;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_insert_item(struct list* self, int index, tbus item)
|
||||
list_insert_item(struct list *self, int index, tbus item)
|
||||
{
|
||||
tbus* p;
|
||||
int i;
|
||||
|
||||
if (index == self->count)
|
||||
{
|
||||
list_add_item(self, item);
|
||||
return;
|
||||
}
|
||||
if (index >= 0 && index < self->count)
|
||||
{
|
||||
self->count++;
|
||||
if (self->count > self->alloc_size)
|
||||
tbus *p;
|
||||
int i;
|
||||
|
||||
if (index == self->count)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
self->alloc_size += self->grow_by;
|
||||
p = (tbus*)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
g_memcpy(p, self->items, sizeof(tbus) * i);
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
list_add_item(self, item);
|
||||
return;
|
||||
}
|
||||
for (i = (self->count - 2); i >= index; i--)
|
||||
|
||||
if (index >= 0 && index < self->count)
|
||||
{
|
||||
self->items[i + 1] = self->items[i];
|
||||
self->count++;
|
||||
|
||||
if (self->count > self->alloc_size)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
self->alloc_size += self->grow_by;
|
||||
p = (tbus *)g_malloc(sizeof(tbus) * self->alloc_size, 1);
|
||||
g_memcpy(p, self->items, sizeof(tbus) * i);
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
|
||||
for (i = (self->count - 2); i >= index; i--)
|
||||
{
|
||||
self->items[i + 1] = self->items[i];
|
||||
}
|
||||
|
||||
self->items[index] = item;
|
||||
}
|
||||
self->items[index] = item;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* append one list to another using strdup for each item in the list */
|
||||
/* begins copy at start_index, a zero based index on the soure list */
|
||||
void APP_CC
|
||||
list_append_list_strdup(struct list* self, struct list* dest, int start_index)
|
||||
list_append_list_strdup(struct list *self, struct list *dest, int start_index)
|
||||
{
|
||||
int index;
|
||||
tbus item;
|
||||
char* dup;
|
||||
|
||||
for (index = start_index; index < self->count; index++)
|
||||
{
|
||||
item = list_get_item(self, index);
|
||||
dup = g_strdup((char*)item);
|
||||
list_add_item(dest, (tbus)dup);
|
||||
}
|
||||
int index;
|
||||
tbus item;
|
||||
char *dup;
|
||||
|
||||
for (index = start_index; index < self->count; index++)
|
||||
{
|
||||
item = list_get_item(self, index);
|
||||
dup = g_strdup((char *)item);
|
||||
list_add_item(dest, (tbus)dup);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
list_dump_items(struct list* self)
|
||||
list_dump_items(struct list *self)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (self->count == 0)
|
||||
{
|
||||
g_writeln("List is empty");
|
||||
}
|
||||
for (index = 0; index < self->count; index++)
|
||||
{
|
||||
g_writeln("%d: %s", index, list_get_item(self, index));
|
||||
}
|
||||
int index;
|
||||
|
||||
if (self->count == 0)
|
||||
{
|
||||
g_writeln("List is empty");
|
||||
}
|
||||
|
||||
for (index = 0; index < self->count; index++)
|
||||
{
|
||||
g_writeln("%d: %s", index, list_get_item(self, index));
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,279 +1,314 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
#include "xrdp-freerdp.h"
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
char *APP_CC
|
||||
convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
|
||||
int width, int height, int *palette)
|
||||
{
|
||||
char *out;
|
||||
char *src;
|
||||
char *dst;
|
||||
int i;
|
||||
int j;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
int pixel;
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
out = (char *)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
freerdp wrapper
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR8(red, green, blue);
|
||||
*dst = pixel;
|
||||
src++;
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
return out;
|
||||
}
|
||||
|
||||
#include "xrdp-freerdp.h"
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16 *)dst) = pixel;
|
||||
src++;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8 *)src);
|
||||
pixel = palette[pixel];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32 *)dst) = pixel;
|
||||
src++;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16 *)src);
|
||||
SPLITCOLOR16(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32 *)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
blue = *((tui8 *)src);
|
||||
src++;
|
||||
green = *((tui8 *)src);
|
||||
src++;
|
||||
red = *((tui8 *)src);
|
||||
src++;
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32 *)dst) = pixel;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
char* APP_CC
|
||||
convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
int width, int height, int* palette)
|
||||
g_writeln("convert_bitmap: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns color or 0 */
|
||||
int APP_CC
|
||||
convert_color(int in_bpp, int out_bpp, int in_color, int *palette)
|
||||
{
|
||||
char* out;
|
||||
char* src;
|
||||
char* dst;
|
||||
int i;
|
||||
int j;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
int pixel;
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
out = (char*)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
int pixel;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
|
||||
if ((in_bpp == 1) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color == 0 ? 0 : 0xffffff;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = palette[pixel];
|
||||
pixel = palette[in_color];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR8(red, green, blue);
|
||||
*dst = pixel;
|
||||
src++;
|
||||
dst++;
|
||||
}
|
||||
return pixel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = palette[pixel];
|
||||
pixel = palette[in_color];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16*)dst) = pixel;
|
||||
src++;
|
||||
dst += 2;
|
||||
}
|
||||
return pixel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui8*)src);
|
||||
pixel = palette[pixel];
|
||||
pixel = palette[in_color];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
src++;
|
||||
dst += 4;
|
||||
}
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = in_color;
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
*((tui16*)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
return pixel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
pixel = in_color;
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = *((tui16*)src);
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
SPLITCOLOR16(red, green, blue, pixel);
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char*)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
for (i = 0; i < height; i++)
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
blue = *((tui8*)src);
|
||||
src++;
|
||||
green = *((tui8*)src);
|
||||
src++;
|
||||
red = *((tui8*)src);
|
||||
src++;
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
*((tui32*)dst) = pixel;
|
||||
dst += 4;
|
||||
}
|
||||
return in_color;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
g_writeln("convert_bitmap: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns color or 0 */
|
||||
int APP_CC
|
||||
convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
{
|
||||
int pixel;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
|
||||
if ((in_bpp == 1) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color == 0 ? 0 : 0xffffff;
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR8(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
SPLITCOLOR32(red, green, blue, pixel);
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
pixel = in_color;
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
SPLITCOLOR15(red, green, blue, pixel);
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
SPLITCOLOR16(red, green, blue, pixel);
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
g_writeln("convert_color: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
g_writeln("convert_color: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff