Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

bimbambumbum

@bimbambumbum
About
Posts
26
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • how to read value at specifix XML node
    B bimbambumbum

    Hi Can I please ask you to elaborate on your approach? For example provide an example. I tried this:

            XmlDocument d = new XmlDocument();
            d.Load("XmlData2.xml");
            var tmp = d.SelectSingleNode("//xx\[@atty='3' and @attz='0'\]/\*\[name()='min' or name()='max'\]");
            //var tmp = d.SelectSingleNode("//xx\[@atty='3' and @attz='0'\]/\*\[name()='min'\]");
    

    but I don't get the right values when inspecting the tmp variable. Thanks

    C# tutorial question xml

  • how to read value at specifix XML node
    B bimbambumbum

    Thanks gentlemen..this looks like a great starting point! Appreciate it

    C# tutorial question xml

  • how to read value at specifix XML node
    B bimbambumbum

    Hello, How can I obtain the value from a specific node in my XML file? For example please consider the xml structure below. How would I for instance obtain "max" and "min" values for node

    and in case it requires a different search method I would also like to know how to obtain the value at node

    0

    ? Anxious to learn how to do this Best Regards Tom

      0
      0
    
    0
      0
    
    0
      0
    

    0
    0
    0
    0
    0

    C# tutorial question xml

  • adding a panel to a form.
    B bimbambumbum

    Hi Luc You are a true gentleman..and fast responder too :) Actually your bitmap manipulation looks the same as the code I did initially (presented in the other thread) so I was happy to see some similarity. The threading coding I'm not familar with but I think that I might get where I want if I can just declare and use the panel the same way as you do. You code doesn't show that unfortunately. I'd hate to ask you for more help because I know I've been asking you too much...so if you just send me a notification when you post your article next week (or whenever it is shared) I'd be happy. Added: Hey it looks like that the picturebox should be added to the panel itself ...I thought one could put in a bitmap directly on the panel. Hopefully doing that will solve my flickering problem! Thanks for your help and patience :) Tom

    modified on Saturday, September 25, 2010 5:46 PM

    .NET (Core and Framework) question

  • adding a panel to a form.
    B bimbambumbum

    Hi Luc Hmmm, maybe I should just realize that I'm not at a sufficient level to pull this off :( 1. I will try your suggestion also! 2. The reason for doing the this.controls.add(myPanel) was because if I instantiated a panel and didn't do this then I never got to see it in the windows form. 3. This was the only way for me to see the bitmap inside the panel. Searched google and didn't find any other options so I thought this was the right way. what is the right way to do it? 4. Yeah, I'm disappointed too. I read your replies again and again and didn't really understand the circular buffer handling scheme... Guess I should have asked for that explicitly. If you have the full code I'd be happy to see it. I'm thinking about going back to OpenGL I think that is easier for me since I once succeeded doing this in that framework. Correction: I DO understand your circular buffer handling in principle (I basically do it that way every day for audio processing at work) but not within a panel in .NET. Thanks for your effort Tom

    modified on Saturday, September 25, 2010 11:52 AM

    .NET (Core and Framework) question

  • adding a panel to a form.
    B bimbambumbum

    Hi Luc I'm about to give up on the panel approach and just use the dramimage-method and live with the flickering. Below you can see me panel approach...it does work but it flickers just a much as the drawimage approach. Do you mind taking a look at my code and tell me what I'm doing wrong? I'm not into the terminology of windows programming so I'd appreciate a no-brainer description on how to do this :) My drawing code looks like this:

            g = pe.Graphics;
    
            int H = myBitmap.Height;
            int W = myBitmap.Width;
    
            Rectangle rect = new Rectangle(0, 0, W, H);
            myBitmapData = myBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, myBitmap.PixelFormat);
    
            // Get the address of the first line.
            IntPtr ptr = myBitmapData.Scan0;
    
            // Declare an array to hold the bytes of the bitmap.
            int bytes = myBitmapData.Stride \* H;
            byte\[\] rgbValues = new byte\[bytes\];
    
            // Copy the RGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
    
            // Shift the first N-1 columns one pixel to the right
            for (int ii = 0; ii < H; ii++)
                for (int jj = (ii + 1) \* (3 \* W) - 1; jj > (ii \* W \* 3) + 3; jj -= 3)
                {
                    rgbValues\[jj\] = rgbValues\[jj-3\];
                    rgbValues\[jj-1\] = rgbValues\[jj-4\];
                    rgbValues\[jj-2\] = rgbValues\[jj-5\];
                }
    
            // fill in some random data in the first column
            int offset = W \* 3;
            for (int counter = 0; counter < H; counter += 1)
            {
                rgbValues\[counter \* offset\] = (byte)rnd.Next(255);
                rgbValues\[counter \* offset + 1\] = (byte)rnd.Next(255);
                rgbValues\[counter \* offset + 2\] = (byte)rnd.Next(255);
            }
    
            // Copy the RGB values back to the bitmap
            System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);
    
            // Unlock the bits.
            myBitmap.UnlockBits(myBitmapData);
            myPanel.Location = new Point(XREF, YREF);
            myPanel.Width = myBitmap.Width;
            myPanel.Height = myBitmap.Height;
            myPanel.BackgroundImage = myBitmap;
            this.Controls.Add(myPanel);
    

    My panel class (read that double buffering with a panel should be done like this):

    public class DoubleBufferPanel : Panel
    {

    .NET (Core and Framework) question

  • adding a panel to a form.
    B bimbambumbum

    Aaah, ok! So you are doing a spectrum-analyzer (frequency vs gain) and not a spectrogram (frequency vs. time vs. gain) - like this one: http://www.youtube.com/watch?v=UcBDSoVs42M[^] Or am I missing something? I have the bitmapdata ready and also the FFT data ready to be injected and then I need to move data around inside the bitmapdata to make the shift of the bitmap. I need to do this the fastest way! for now I will just do it the heavy way using a loop. Would be better though to copy blocks around using a rectangle() suggestions are appriciated! Thx Tom

    .NET (Core and Framework) question

  • adding a panel to a form.
    B bimbambumbum

    Hey Thanks, Will you let me in on how you manipulate the bitmapdata - that is ...working with the two spectrogram sections? I have the panel shown and can fill-in data. I'm looking and looking and .NET is so huge and hard to get into I think. I guess I can solve this by copying data around in a loop but that doesn't seem elegant! Cheers Tom

    modified on Wednesday, September 22, 2010 8:50 PM

    .NET (Core and Framework) question

  • adding a panel to a form.
    B bimbambumbum

    hmmm, I as missing: // Add the Panel control to the form. this.Controls.Add(panel1); RESOLVED

    .NET (Core and Framework) question

  • adding a panel to a form.
    B bimbambumbum

    Hi If I add a panel graphically in VS2010 I can make it display an image but if I manually add a panel by writing code I can't make it visible. Do I have to associate it to the form? I have given the manually defined panel an x,y,width and height and I true'ed the visible flag. Painfully Tom

    .NET (Core and Framework) question

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    One last thing... Will my spectrogram shift more smoothly if I do it the panel way? Cheers Tom

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    Hi Luc Thanks for your comments. I get your points - I think :) Will try to follow your recipe when I have time tomorrow. If you have an example I can steal from that would be great... Thanks Thomas

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    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)
    
    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    Hi Luc Glad to hear you are in good progress. I will take a look at the article you are refering to. I've advanced a bit tonight myself because the spectrogram is now up running. I'm currently using drawImage() which seems to do well. My laptop (Lenovo T61p) uses about 20% of it's resources but the app also does FFTs 50 times a second and computes the log-spectrum of these FFT outputs which costs a little too so I'm pretty impressed with the GDI performance. Even though I running double-buffering I still think my 768x1024 pixel spectrogram does some flickering..do you have a way to get rid of this? Also, I need an efficient way of mapping from FFT log-outputs to a colorrange...you know of an easy way of doing this? Sorry for all the question...I have a lot to learn with .NET (and programming in general besides Matlab) Addition: I guess the flickering comes because I'm manipulating the bitmap directly and not bitmapdata. If that is the case maybe drawimage is not such a good option???? Thx Thomas

    modified on Tuesday, September 21, 2010 12:09 AM

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    Hi Luc, Sounds cool! looking forward to see what you come up with. For the spectrogram I wouldn't worry about axis for my app but if you want to write an article you might want to put a frequency and time axis and possible a colorbar which maps the spectrogram colors to an intensity for the frequency components. Let me know if I can contribute in any way...going to bed know Thx Tom

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    Hi Luc Thanks for your reply - once more....you are a fast responder :) 1. My matrix is not really a matrix but just an array of bytes of size [3*bitmap.height*bitmap.width] so by the 3 term this should correspond to 24bit but less resolution will be ok for the final application. I want to insert the 20*log10(abs(FFT-bins/2) into each column of the bitmap (FFT-bins/2 could be 256, 512 or 1024). Yes I can define the producer type/format myself. Grayscale is probably fine. "..Trace in the image" - can you elaborate? 2. OK, I'm starting to understand now. 3. Yes I get the point. I just read that scrollWindow might be what I'm looking as it offers horizontal shifting by a pixel which is basically what I'm looking for. You know of this method? 4. Image size could be up to 1024x1024. Update frequency is likely to be around 25Hz. I can share the code if you are interested but I'm thinking you can do a much better job than me. 5. There is another spectrum analyzis tool I'm thinking of adding to my application. Maybe that can beef up your article if you are interested. Thx Tom

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    Hi Thanks for your support! OK I understand your way of doing circular buffering. Do you know which copying method is fastest? I've been searching for options and "bitblt" seems the fastest method - are you familiar with it and is it recommendable? Also, as you might have guessed I'm a newbie with C# (actually I'm only good at Matlab) and I'm trying to understand GDI better ...but it's challenging. Can I do the spectrogram using the bitmap itself and manipulate data in it for every update - I gues I can but is it efficient MIPS wise? Can you please provide me a few keywords on how you would go about this? From the examples I've found searching googling bitmapdata seems a component I might have to use but I can't understand for what reason. MSDN doc seems sparse :( http://msdn.microsoft.com/en-us/library/system.drawing.imaging.bitmapdata.aspx Sorry for all the questioning Thx Tom

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • How to shift a bitmap efficiently (Spectrogram Application) [modified]
    B bimbambumbum

    Hi I'm working on a Spectrum analyzer application and need some help to get the graphics updated in an optimal manner. Whenever my program receives a new block of audio data I do an FFT and I then update the oldest FFT data (a column) in my 2D-matrix which is then copied to a bitmap for display. So this spectrogram is shifted horizontally as data arrives in blocks. I see two options for achieving the shifting of the NxM bitmap whenever a new FFT output block arrives: 1. Copy columns [0:M-2] to [1:M-1] and then copy in the new FFT data...hope the notation makes sense. This requires a lot of memory copying and I hope to avoid that using GDI. 2. Replace the "oldest" column (the matrix works as a circular buffer in the time-direction) and let GDI ensure that when wrap-around happens GDI the remaining columns (the columns up to the column where the new FFT data resides) are copied to the bitmap. I once did a spectrum Analyzer in C++ project using OpenGL that supports this functionality. Can find the project anymore..I tried to look for it to find the name of the instruction used. Does GDI/GDI+ support this? Do any of you guys know how I get to do this efficiently? Thx Tom

    modified on Sunday, September 19, 2010 8:00 PM

    .NET (Core and Framework) graphics c++ winforms game-dev performance

  • picturebox.visible problem
    B bimbambumbum

    Hmm, just solved it myself... when I replace: BitmapCanvas.Visible = false; With: this.BitmapCanvas.Visible = false; Then I can make the visible picturebox go invisible! Wonder why that is needed? Probably a no-brainer Thomas

    .NET (Core and Framework) question help

  • picturebox.visible problem
    B bimbambumbum

    Hi I'm a newbie struggling with a picturebox. At construction time I load a jpg image into a picturebox and I have 3 radio-buttons that dictate what what is drawn in the GUI. When the picturebox is enabled & visible at construction time then it stays visible even if I make it invisible later by pressing a radiobutton (picturebox1.visible = false) . Can someone please tell me what I'm missing? Regards Tom

    .NET (Core and Framework) question help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups