Hi Luc Here is the core of my bitmap shifting. If you run it you can see that the shifting flickers a little and I would like to avoid that. Hope you have a simple way of getting rid of the flickering. Sorry for the messy code....Mind you I'm a newbie :)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using fftwlib;
namespace GDI_evaluation
{
public partial class Form1 : Form
{
Timer timer = new Timer();
Graphics g;
int XREF = 50;
int YREF = 50;
// Bitmap
Bitmap myBitmap;
Random rnd;
int tIndx = 0;
public Form1()
{
InitializeComponent();
rnd = new Random();
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer, true);
myBitmap = new Bitmap(768, 512, PixelFormat.Format24bppRgb);
timer.Tick += new EventHandler(timer\_tick);
timer.Interval = 1000 / 25; // opdater grafik 50 /sekund!!!
timer.Enabled = true;
timer.Start();
}
void timer\_tick(object sender, EventArgs e)
{
this.Refresh(); // Update GUI
}
private void Form1\_Paint(object sender, PaintEventArgs e)
{
}
protected override void OnPaint(PaintEventArgs pe)
{
g = pe.Graphics;
Rectangle block1 = new Rectangle(XREF + tIndx, YREF, myBitmap.Width - tIndx, myBitmap.Height);
g.DrawImage(myBitmap, block1, 0, 0, myBitmap.Width - tIndx, myBitmap.Height, GraphicsUnit.Pixel);
Rectangle block2 = new Rectangle(XREF, YREF, tIndx, myBitmap.Height);
g.DrawImage(myBitmap, block2, myBitmap.Width - tIndx, 0, tIndx, myBitmap.Height, GraphicsUnit.Pixel);
int tIndx2 = tIndx - 1;
if (tIndx2 < 0)
tIndx2 = myBitmap.Width - 1;
// Insert new FFT data
for (int ii = 0; ii < myBitmap.Height; ii++)
myBitmap.SetPixel(myBitmap.Width - 1 - tIndx2, ii, Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)));
if (++tIndx == myBitmap.Width)