Code example for Bitmap

Methods: getPixelssetPixelsetPixels

0
	 
	public void plotSpectrum(int[] samples,int filterLow,int filterHigh,int sampleRate) {
 
		// scroll the waterfall down 
		 
		waterfall.getPixels(pixels,0,WIDTH,0,0,WIDTH,HEIGHT-1);
		waterfall.setPixels(pixels, 0, WIDTH, 0, 1, WIDTH, HEIGHT-1);
		 
		int p=0;
		float sample;
		float previous=0.0F;
		for(int i=0;i<WIDTH;i++) {
			sample=(float)Math.floor(((float)spectrumHigh-(float)samples[i])*(float)HEIGHT/(float)(spectrumHigh-spectrumLow));
			if(i==0) {
				points[p++]=(float)i;
				points[p++]=sample;
			} else { 
				points[p++]=(float)i;
				points[p++]=previous;
			} 
			 
			points[p++]=(float)i;
	        points[p++]=sample;
	        
	        waterfall.setPixel(i,0,calculatePixel(samples[i]));
	         
	        previous=sample;
		} 
		 
		this.filterLow=filterLow;