static void ApplyFinalColors(HighlightDataColor *Colors) { //Обработаем black on black чтоб после наследования были правильные цвета. ApplyBlackOnBlackColors(Colors); for (int j=0; j<2; j++) for (int i=0; i<4; i++) { //Если какой то из текущих цветов (fore или back) прозрачный //то унаследуем соответствующий цвет с панелей. if(IS_TRANSPARENT(Colors->Color[j][i].BackgroundColor)) { Colors->Color[j][i].BackgroundColor=Global->Opt->Palette.CurrentPalette[PalColor[i]-COL_FIRSTPALETTECOLOR].BackgroundColor; if(Global->Opt->Palette.CurrentPalette[PalColor[i]-COL_FIRSTPALETTECOLOR].Flags&FCF_BG_4BIT) { Colors->Color[j][i].Flags|=FCF_BG_4BIT; } else { Colors->Color[j][i].Flags&=~FCF_BG_4BIT; } } if(IS_TRANSPARENT(Colors->Color[j][i].ForegroundColor)) { Colors->Color[j][i].ForegroundColor=Global->Opt->Palette.CurrentPalette[PalColor[i]-COL_FIRSTPALETTECOLOR].ForegroundColor; if(Global->Opt->Palette.CurrentPalette[PalColor[i]-COL_FIRSTPALETTECOLOR].Flags&FCF_FG_4BIT) { Colors->Color[j][i].Flags|=FCF_FG_4BIT; } else { Colors->Color[j][i].Flags&=~FCF_FG_4BIT; } } } //Если символ пометки прозрачный то его как бы и нет вообще. if (Colors->MarkChar&0x00FF0000) Colors->MarkChar=0; //Параноя но случится может: //Обработаем black on black снова чтоб обработались унаследованые цвета. ApplyBlackOnBlackColors(Colors); }
/** * @brief Render a bitmap mask for an image. * * @param in image to render a bitmap mask from * @param out bitmap mask * * @return 1 (ok) or 0 (error) * * @note As a side effect, transparent pixels of @a in will be rendered black. */ int bpRenderMask(const guiImage *in, guiImage *out) { uint32_t *buf; unsigned long x, y; unsigned long i = 0, c = 0; unsigned char tmp = 0, b = 1; int shaped = 0; out->Width = in->Width; out->Height = in->Height; out->Bpp = 1; out->ImageSize = ((out->Width + 7) / 8) * out->Height; out->Image = calloc(1, out->ImageSize); if (!out->Image) { mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] not enough memory: %lu\n", out->ImageSize); return 0; } buf = (uint32_t *)in->Image; for (y = 0; y < in->Height; y++) { for (x = 0; x < in->Width; x++) { if (!IS_TRANSPARENT(buf[i])) tmp |= b; else { buf[i] = 0; // pixel should be black (if transparency isn't supported) shaped = 1; } i++; b <<= 1; if (b == 0) { out->Image[c++] = tmp; tmp = 0; b = 1; } } if (b != 1) { out->Image[c++] = tmp; tmp = 0; b = 1; } } if (!shaped) bpFree(out); mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] 1 bpp conversion size: %lu\n", out->ImageSize); return 1; }
static void PutImage(guiImage *bf, int x, int y, int max, int ofs) { int i = 0, ix, iy; uint32_t *buf = NULL; uint32_t *drw = NULL; register uint32_t tmp; /* register uint32_t yc; */ if (!bf || (bf->Image == NULL)) return; i = bf->Width * (bf->Height / max) * ofs; buf = (uint32_t *)image_buffer; drw = (uint32_t *)bf->Image; #if 1 for (iy = y; iy < (int)(y + bf->Height / max); iy++) for (ix = x; ix < (int)(x + bf->Width); ix++) { tmp = drw[i++]; if (!IS_TRANSPARENT(tmp)) buf[iy * image_width + ix] = tmp; } #else yc = y * image_width; for (iy = y; iy < (int)(y + bf->Height / max); iy++) { for (ix = x; ix < (int)(x + bf->Width); ix++) { tmp = drw[i++]; if (!IS_TRANSPARENT(tmp)) buf[yc + ix] = tmp; } yc += image_width; } #endif }
/* ============== TransparentByteImage ============== */ void TransparentByteImage( void ) { // Remap all pixels of color 0,0,255 to index 255 and remap index 255 to something else byte transtable[256], *image; int i, j, firsttrans; firsttrans = -1; for ( i = 0; i < 256; i++ ) { if ( IS_TRANSPARENT( (lbmpalette+(i*3)) ) ) { transtable[i] = 255; if ( firsttrans < 0 ) firsttrans = i; } else transtable[i] = i; } // If there is some transparency, translate it if ( firsttrans >= 0 ) { if ( !IS_TRANSPARENT( (lbmpalette+(255*3)) ) ) transtable[255] = firsttrans; image = byteimage; for ( j = 0; j < byteimageheight; j++ ) { for ( i = 0; i < byteimagewidth; i++ ) { *image = transtable[*image]; image++; } } // Move palette entry for pixels previously mapped to entry 255 lbmpalette[ firsttrans*3 + 0 ] = lbmpalette[ 255*3 + 0 ]; lbmpalette[ firsttrans*3 + 1 ] = lbmpalette[ 255*3 + 1 ]; lbmpalette[ firsttrans*3 + 2 ] = lbmpalette[ 255*3 + 2 ]; lbmpalette[ 255*3 + 0 ] = TRANSPARENT_R; lbmpalette[ 255*3 + 1 ] = TRANSPARENT_G; lbmpalette[ 255*3 + 2 ] = TRANSPARENT_B; } }
/** * @brief Put a part of a #guiImage image into a (window's) draw buffer. * * @param x x position where to start in the draw buffer * @param y y position where to start in the draw buffer * @param drawbuf draw buffer where the image should be put in * @param drawbuf_width width of the draw buffer * @param img image (containing several phases, i.e. image parts) * @param parts number of parts in the image * @param index index of the part of the image to be drawn * @param below flag indicating whether the image parts are arranged * below each other or side by side */ static void PutImage(int x, int y, uint32_t *drawbuf, int drawbuf_width, guiImage *img, int parts, int index, int below) { register int i, ic, yc; register uint32_t pixel; int xlimit, ylimit, ix, iy; uint32_t *pixels; if (!img || !img->Image) return; if (below) { i = img->Width * (img->Height / parts) * index; xlimit = x + img->Width; ylimit = y + img->Height / parts; } else { i = (img->Width / parts) * index; xlimit = x + img->Width / parts; ylimit = y + img->Height; } pixels = (uint32_t *)img->Image; yc = y * drawbuf_width; for (iy = y; iy < ylimit; iy++) { ic = i; for (ix = x; ix < xlimit; ix++) { pixel = pixels[i++]; if (!IS_TRANSPARENT(pixel)) drawbuf[yc + ix] = pixel; } if (!below) i = ic + img->Width; yc += drawbuf_width; } }