Jump to content

Am I doing this right? (get / set pixel on a surface)


Recommended Posts

i am trying to copy pixels from the "this.EnvironmentParameters.SourceSurface" using the fallowing code but the resulting image does not contain any of the expected pixels ...

//nudHeight and nudWidth are numeric updown controls
// info.BlockImage is a "Image" type
//lbBlocks is a owner drawn listbox control so I can preview the block that was made
//imageSource is set to "this.EnvironmentParameters.SourceSurface"

       private void button1_Click(object sender, EventArgs e)
       {
           InfoItem info = new InfoItem();
           info.BlockImage = new Bitmap((int)this.nudWidth.Value, (int)this.nudHeight.Value, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
           Graphics g = Graphics.FromImage(info.BlockImage);
           for (int idy = 0; idy < this.imageSource.Height; idy++)
           {
               for (int idx = 0; idx < this.imageSource.Width; idx++)
               {
                   ColorBgra col;
                   col = this.imageSource.GetPoint(idx, idy);
                   g.DrawLine(new Pen(Color.FromArgb(col.A, col.R, col.G, col.), idx, idy, idx, idy);
                  // g.DrawLine(new Pen(Color.FromArgb(Math.Abs(col.A - 255), col.R, col.G, col.), idx, idy, idx, idy);
               }
           }
           g = null;
           info.Name = "First block";
           // this.blocks.Add(info);
           this.lbBlocks.Items.Add(info);
       }

... this is my first time trying to create a paint.net effect so bear with me. I am assuming that "this.EnvironmentParameters.SourceSurface" refers the the image. So my question really is how do I grab pixels or a rectangle of pixels and store them in a regular System.Drawing.Image obj?

Link to comment
Share on other sites

Drawing to the source surface is bad, mkay? ...like "crossing the streams" bad. Don't do it.

If you've never written an effect before, you should probably start here: http://www.boltbait.com/pdn/codelab/help/overview.html

If you have additional questions after reading that page (and any linked pages that look interesting), just post them.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...