Exemplo n.º 1
0
Arquivo: swscale.c Projeto: Tilka/vlc
static void Convert( filter_t *p_filter, struct SwsContext *ctx,
                     picture_t *p_dst, picture_t *p_src, int i_height, int i_plane_start, int i_plane_count,
                     bool b_swap_uvi, bool b_swap_uvo )
{
    uint8_t palette[AVPALETTE_SIZE];

    uint8_t *src[4]; int src_stride[4];
    uint8_t *dst[4]; int dst_stride[4];

    GetPixels( src, src_stride, p_src, i_plane_start, i_plane_count, b_swap_uvi );
    if( p_filter->fmt_in.video.i_chroma == VLC_CODEC_RGBP )
    {
        memset( palette, 0, sizeof(palette) );
        if( p_filter->fmt_in.video.p_palette )
            memcpy( palette, p_filter->fmt_in.video.p_palette->palette,
                    __MIN( sizeof(video_palette_t), AVPALETTE_SIZE ) );
        src[1] = palette;
        src_stride[1] = 4;
    }

    GetPixels( dst, dst_stride, p_dst, i_plane_start, i_plane_count, b_swap_uvo );

#if LIBSWSCALE_VERSION_INT  >= ((0<<16)+(5<<8)+0)
    sws_scale( ctx, src, src_stride, 0, i_height,
               dst, dst_stride );
#else
    sws_scale_ordered( ctx, src, src_stride, 0, i_height,
                       dst, dst_stride );
#endif
}
Exemplo n.º 2
0
int FTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
{
	PalEntry *palette = screen->GetPalette();
	for(int i=1;i<256;i++) palette[i].a = 255;	// set proper alpha values
	bmp->CopyPixelData(x, y, GetPixels(), Width, Height, Height, 1, rotate, palette, inf);
	for(int i=1;i<256;i++) palette[i].a = 0;
	return 0;
}
Exemplo n.º 3
0
	//------------------------------------------------------------------------------------
	// Building the mipmap for a tile based image
	//------------------------------------------------------------------------------------
	bool Image::BuildTileMipMap( int NumCols, int NumRows )
	{
		BuildMipMaps();

		int tW			= m_iWidth  / NumCols;
		int tH			= m_iHeight / NumRows;
		int mipmapLevel = 1;
		int maxmipmaplevel = 0;
		u8* pTempData	= KGE_NEW_ARRAY(u8, tW * tH * 4);
		int t = 1, tth, ttw;

		Image* imgTemp = KGE_NEW(Image)("Temp");
		imgTemp->CreateImage(tW, tH, 1, 4, EIF_RGBA, 0);

		int wi = m_iWidth;
		while (wi > NumCols)
		{
			wi /= 2;
			maxmipmaplevel++;
		}

		io::Logger::Log(io::ELM_Warning, "mmm = %d", maxmipmaplevel);

		for ( int j = 0; j < maxmipmaplevel - 1; j++)
		{
			for (int y = 0; y < NumRows; y++)
			{
				for (int x = 0; x < NumCols; x++)
				{
					GetPixels(x * tW , y * tH, 1, tW, tH, 1, EIF_BGRA, pTempData);
					imgTemp->SetData(pTempData);
					t = math::pow(2, mipmapLevel);
					ttw = tW / t;
					tth = tH / t;
					imgTemp->Scale(ttw, tth, 1);
					SetPixels(x * ttw, y * tth, 1, ttw, tth, 1, EIF_BGRA,
						imgTemp->GetData(), mipmapLevel);

				} // for x

			} // for y

			mipmapLevel++;

		} // for j

		// TODO: Not tested
		KGE_DELETE_ARRAY(pTempData);
		KGE_DELETE(imgTemp, Image);

		return true;

	} // BuildTileMipMap
Exemplo n.º 4
0
//===========================================================================
//
// True Color texture copy function
// This excludes all the cases that force downconversion to the
// base palette because they wouldn't be used anyway.
//
//===========================================================================
void FGLBitmap::CopyPixelDataRGB(int originx, int originy,
								const uint8_t * patch, int srcwidth, int srcheight, int step_x, int step_y,
								int rotate, int ct, FCopyInfo *inf,	int r, int g, int b)
{
	if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
	{
		uint8_t *buffer = GetPixels() + 4*originx + Pitch*originy;
		for (int y=0;y<srcheight;y++)
		{
			copyfuncs[ct](&buffer[y*Pitch], &patch[y*step_y], srcwidth, step_x, (uint8_t)r, (uint8_t)g, (uint8_t)b);
		}
	}
}
Exemplo n.º 5
0
//===========================================================================
//
// Paletted to True Color texture copy function
//
//===========================================================================
void FGLBitmap::CopyPixelData(int originx, int originy, const uint8_t * patch, int srcwidth, int srcheight, 
										int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf)
{
	PalEntry penew[256];

	int x,y,pos,i;

	if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
	{
		uint8_t *buffer = GetPixels() + 4*originx + Pitch*originy;

		if (translation > 0)
		{
			PalEntry *ptrans = GLTranslationPalette::GetPalette(translation);
			if (ptrans && !alphatrans)
			{
				for (i = 0; i < 256; i++)
				{
					penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000);
				}
			}
			else if (ptrans)
			{
				memcpy(penew, ptrans, 256 * sizeof(PalEntry));
			}
		}
		else
		{
			memcpy(penew, palette, 256*sizeof(PalEntry));
		}

		// convert the image according to the translated palette.
		for (y=0;y<srcheight;y++)
		{
			pos=(y*Pitch);
			for (x=0;x<srcwidth;x++,pos+=4)
			{
				int v=(unsigned char)patch[y*step_y+x*step_x];
				if (penew[v].a!=0)
				{
					buffer[pos]   = penew[v].r;
					buffer[pos+1] = penew[v].g;
					buffer[pos+2] = penew[v].b;
					buffer[pos+3] = penew[v].a;
				}
			}
		}
	}
}
Exemplo n.º 6
0
// Create a DIB for the current device from our PNG.
bool PNG::Bitmap::ToDIB(CBitmap &bitmap, CDC *dc) const
//-----------------------------------------------------
{
	BITMAPINFOHEADER bi;
	MemsetZero(bi);
	bi.biSize = sizeof(BITMAPINFOHEADER);
	bi.biWidth = width;
	bi.biHeight = -(int32_t)height;
	bi.biPlanes = 1;
	bi.biBitCount = 32;
	bi.biCompression = BI_RGB;
	bi.biSizeImage = width * height * 4;

	if(dc == nullptr) dc = CDC::FromHandle(GetDC(NULL));
	return bitmap.CreateCompatibleBitmap(dc, width, height)
		&& SetDIBits(dc->GetSafeHdc(), bitmap, 0, height, GetPixels(), reinterpret_cast<BITMAPINFO *>(&bi), DIB_RGB_COLORS);
}
Exemplo n.º 7
0
// For this generic implementation, we just call GetPixels and copy that data
// to the buffer. Texture formats that can do better than paletted images
// should provide their own implementation that may preserve the original
// color data. Note that the buffer expects row-major data, since that's
// generally more convenient for any non-Doom image formats, and it doesn't
// need to be used by any of Doom's column drawing routines.
void FTexture::FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt)
{
	const BYTE *pix;
	int x, y, w, h, stride;

	w = GetWidth();
	h = GetHeight();

	switch (fmt)
	{
	case TEX_Pal:
	case TEX_Gray:
		pix = GetPixels();
		stride = pitch - w;
		for (y = 0; y < h; ++y)
		{
			const BYTE *pix2 = pix;
			for (x = 0; x < w; ++x)
			{
				*buff++ = *pix2;
				pix2 += h;
			}
			pix++;
			buff += stride;
		}
		break;

	case TEX_RGB:
	{
		FCopyInfo inf = {OP_OVERWRITE, BLEND_NONE, {0}, 0, 0};
		FBitmap bmp(buff, pitch, pitch/4, height);
		CopyTrueColorPixels(&bmp, 0, 0, 0, &inf); 
		break;
	}

	default:
		I_Error("FTexture::FillBuffer: Unsupported format %d", fmt);
	}
}
Exemplo n.º 8
0
void FTexture::CopyToBlock (BYTE *dest, int dwidth, int dheight, int xpos, int ypos, int rotate, const BYTE *translation)
{
	const BYTE *pixels = GetPixels();
	int srcwidth = Width;
	int srcheight = Height;
	int step_x = Height;
	int step_y = 1;
	FClipRect cr = {0, 0, dwidth, dheight};

	if (ClipCopyPixelRect(&cr, xpos, ypos, pixels, srcwidth, srcheight, step_x, step_y, rotate))
	{
		dest += ypos + dheight * xpos;
		if (translation == NULL)
		{
			for (int x = 0; x < srcwidth; x++)
			{
				int pos = x * dheight;
				for (int y = 0; y < srcheight; y++, pos++)
				{
					// the optimizer is doing a good enough job here so there's no need to optimize this by hand
					BYTE v = pixels[y * step_y + x * step_x]; 
					if (v != 0) dest[pos] = v;
				}
			}
		}
		else
		{
			for (int x = 0; x < srcwidth; x++)
			{
				int pos = x * dheight;
				for (int y = 0; y < srcheight; y++, pos++)
				{
					BYTE v = pixels[y * step_y + x * step_x]; 
					if (v != 0) dest[pos] = translation[v];
				}
			}
		}
	}
}
Exemplo n.º 9
0
int FTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf)
{
	PalEntry *palette = remap->Palette;
	bmp->CopyPixelData(x, y, GetPixels(), Width, Height, Height, 1, rotate, palette, inf);
	return 0;
}
Exemplo n.º 10
0
	std::pair<BYTE*, UINT> Picture::GetAllData()
	{
		auto size = GetPixels();
		WICRect rect = { 0,0,static_cast<INT>(size.first),static_cast<INT>(size.second) };
		return GetBitmapData(rect);
	}
Exemplo n.º 11
0
Arquivo: main.c Projeto: g0orx/pihpsdr
gint update(gpointer data) {
    int result;
    double fwd;
    double rev;
    double exciter;
    int channel=CHANNEL_RX0;
#ifdef PSK
    if(mode==modePSK) {
      channel=CHANNEL_PSK;
    }
#endif
    if(isTransmitting()) {
      channel=CHANNEL_TX;
    }
    GetPixels(channel,0,samples,&result);
    if(result==1) {
        if(display_panadapter) {
#ifdef PSK
          if(mode==modePSK) {
            psk_waterfall_update(samples);
          } else {
#endif
            panadapter_update(samples,isTransmitting());
#ifdef PSK
          }
#endif
        }
        if(!isTransmitting()) {
#ifdef PSK
          if(mode!=modePSK) {
#endif
            if(display_waterfall) {
              waterfall_update(samples);
            }
#ifdef PSK
          }
#endif
        }
    }

    if(!isTransmitting()) {
        double m;
        switch(mode) {
#ifdef PSK
            case modePSK:
                m=(double)psk_get_signal_level();
                meter_update(PSKMETER,m,0.0,0.0,0.0);
                break;
#endif
            default:
                m=GetRXAMeter(CHANNEL_RX0, smeter);
                meter_update(SMETER,m,0.0,0.0,0.0);
                break;
        }
    } else {

        double alc=GetTXAMeter(CHANNEL_TX, alc);

        DISCOVERED *d=&discovered[selected_device];

        double constant1=3.3;
        double constant2=0.095;

        if(d->protocol==ORIGINAL_PROTOCOL) {
            switch(d->device) {
                case DEVICE_METIS:
                    constant1=3.3;
                    constant2=0.09;
                    break;
                case DEVICE_HERMES:
                    constant1=3.3;
                    constant2=0.095;
                    break;
                case DEVICE_ANGELIA:
                    constant1=3.3;
                    constant2=0.095;
                    break;
                case DEVICE_ORION:
                    constant1=5.0;
                    constant2=0.108;
                    break;
                case DEVICE_HERMES_LITE:
                    break;
            }

            int power=alex_forward_power;
            if(power==0) {
                power=exciter_power;
            }
            double v1;
            v1=((double)power/4095.0)*constant1;
            fwd=(v1*v1)/constant2;

            power=exciter_power;
            v1=((double)power/4095.0)*constant1;
            exciter=(v1*v1)/constant2;

            rev=0.0;
            if(alex_forward_power!=0) {
                power=alex_reverse_power;
                v1=((double)power/4095.0)*constant1;
                rev=(v1*v1)/constant2;
            }
         
        } else {
            switch(d->device) {
                case NEW_DEVICE_ATLAS:
                    constant1=3.3;
                    constant2=0.09;
                    break;
                case NEW_DEVICE_HERMES:
                    constant1=3.3;
                    constant2=0.09;
                    break;
                case NEW_DEVICE_HERMES2:
                    constant1=3.3;
                    constant2=0.095;
                    break;
                case NEW_DEVICE_ANGELIA:
                    constant1=3.3;
                    constant2=0.095;
                    break;
                case NEW_DEVICE_ORION:
                    constant1=5.0;
                    constant2=0.108;
                    break;
                case NEW_DEVICE_ORION2:
                    constant1=5.0;
                    constant2=0.108;
                    break;
                case NEW_DEVICE_HERMES_LITE:
                    constant1=3.3;
                    constant2=0.09;
                    break;
            }
        
            int power=alex_forward_power;
            if(power==0) {
                power=exciter_power;
            }
            double v1;
            v1=((double)power/4095.0)*constant1;
            fwd=(v1*v1)/constant2;

            power=exciter_power;
            v1=((double)power/4095.0)*constant1;
            exciter=(v1*v1)/constant2;

            rev=0.0;
            if(alex_forward_power!=0) {
                power=alex_reverse_power;
                v1=((double)power/4095.0)*constant1;
                rev=(v1*v1)/constant2;
            }
        }

/*
fprintf(stderr,"alex_forward_power=%d alex_reverse_power=%d exciter_power=%d fwd=%f rev=%f exciter=%f\n",
               alex_forward_power, alex_reverse_power, exciter_power, fwd, rev, exciter);
*/
        meter_update(POWER,fwd,rev,exciter,alc);
    }

    return TRUE;
}