00001 /***************************************************************************** 00002 * DrawingTidbits.h 00003 ***************************************************************************** 00004 * Copyright (C) 2001 the VideoLAN team 00005 * $Id: DrawingTidbits.h 11664 2005-07-09 06:17:09Z courmisch $ 00006 * 00007 * Authors: Tony Castley <[email protected]> 00008 * Stephan Aßmus <[email protected]> 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 00023 *****************************************************************************/ 00024 00025 #ifndef __DRAWING_TIBITS__ 00026 #define __DRAWING_TIBITS__ 00027 00028 #include <GraphicsDefs.h> 00029 00030 rgb_color ShiftColor(rgb_color , float ); 00031 00032 bool operator==(const rgb_color &, const rgb_color &); 00033 bool operator!=(const rgb_color &, const rgb_color &); 00034 00035 inline rgb_color 00036 Color(int32 r, int32 g, int32 b, int32 alpha = 255) 00037 { 00038 rgb_color result; 00039 result.red = r; 00040 result.green = g; 00041 result.blue = b; 00042 result.alpha = alpha; 00043 00044 return result; 00045 } 00046 00047 const rgb_color kWhite = { 255, 255, 255, 255}; 00048 const rgb_color kBlack = { 0, 0, 0, 255}; 00049 00050 const float kDarkness = 1.06; 00051 const float kDimLevel = 0.6; 00052 00053 void ReplaceColor(BBitmap *bitmap, rgb_color from, rgb_color to); 00054 void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with); 00055 00056 // function can be used to scale the upper left part of 00057 // a bitmap to fill the entire bitmap, ie fromWidth 00058 // and fromHeight must be smaller or equal to the bitmaps size! 00059 // only supported colorspaces are B_RGB32 and B_RGBA32 00060 status_t scale_bitmap( BBitmap* bitmap, 00061 uint32 fromWidth, uint32 fromHeight ); 00062 00063 // bitmaps need to be the same size, or this function will fail 00064 // currently supported conversions: 00065 // B_YCbCr422 -> B_RGB32 00066 // B_RGB32 -> B_RGB32 00067 // B_RGB16 -> B_RGB32 00068 // not yet implemented conversions: 00069 // B_YCbCr420 -> B_RGB32 00070 // B_YUV422 -> B_RGB32 00071 status_t convert_bitmap(BBitmap* inBitmap, BBitmap* outBitmap); 00072 00073 // dims bitmap (in place) by finding the distance of 00074 // the color at each pixel to the provided "center" color 00075 // and shortens that distance by dimLevel 00076 // (dimLevel < 1 -> less contrast) 00077 // (dimLevel > 1 -> more contrast) 00078 // (dimLevel < 0 -> inverted colors) 00079 // currently supported colorspaces: 00080 // B_RGB32 00081 // B_RGBA32 00082 // B_CMAP8 00083 status_t dim_bitmap(BBitmap* bitmap, rgb_color center, 00084 float dimLevel); 00085 00086 rgb_color dimmed_color_cmap8(rgb_color color, rgb_color center, 00087 float dimLevel); 00088 00089 #endif // __DRAWING_TIBITS__