Jump to content
Xtreme .Net Talk

aewarnick

Avatar/Signature
  • Posts

    1052
  • Joined

  • Last visited

Everything posted by aewarnick

  1. I have a very long code and when the editor checks after the code is changed it takes forever!! Can I disable it?
  2. Is locking the bits faster when looping than using SetPixel?
  3. Here is a method that shades the Bitmap a certain color. I notice that alpha is never accessed here when the bits are locked. How do I access alpha besides SetPixel when the image is Locked? public static bool Color(Bitmap b, int red, int green, int blue) { if (red < -255 || red > 255) return false; if (green < -255 || green > 255) return false; if (blue < -255 || blue > 255) return false; BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int stride = bmData.Stride; System.IntPtr Scan0 = bmData.Scan0; unsafe { byte * p = (byte *)(void *)Scan0; int nOffset = stride - b.Width*3; int nPixel; for(int y=0;y<b.Height;++y) { for(int x=0; x < b.Width; ++x ) { nPixel = p[2] + red; nPixel = Math.Max(nPixel, 0); p[2] = (byte)Math.Min(255, nPixel); nPixel = p[1] + green; nPixel = Math.Max(nPixel, 0); p[1] = (byte)Math.Min(255, nPixel); nPixel = p[0] + blue; nPixel = Math.Max(nPixel, 0); p[0] = (byte)Math.Min(255, nPixel); p += 3; } p += nOffset; } } b.UnlockBits(bmData); return true; }
  4. Just use the designer for the Form.
  5. I have seriously considered it but never heard anything really good about it.
  6. You're right, it is cleaner. I guess I just fantisize about C++ sometimes. It can be fun! I am looking up in help right now about how to allow unsafe code in my app so that I can start enjoying myself!
  7. I want C++ flexibility. What is UDT?
  8. What I mean is being able to keep the address of the passed variable all throughout the OptionsForm and directly changing the value.
  9. Sorry, didn't read the code very well. Now I see exactly what you meant. I would change ShowDialogs return type at all. I am still going to try to do this the C++ way for future projects. If you can help with that, I would be happy.
  10. How do I return anything but DialogResult which is of type enum?
  11. Thanks VolteFace. Just to clarify, I did some more testing and found what you said about assigning to the passed variable directly will change the original. That is what I meant up in my post above And also, the variables are not the same, you just looked at them too quick:D. I did make the OptionsForm member public so that it can be accessed, that was my workaround. But I didn't think it was the best way to do things. I think in C++ you can do what I am trying to do, am I right? And if you can in C++ there is probably a way using maybe, unsafe code. Correct?
  12. Here is my Form class' constructor: public OptionsForm(a.graphics.DrawingSurface ds, ref Color transpCol)DrawingSurface is a class, Color is a structure. When I change any of ds's members they change the original members. Now, I know that all classes are passed by ref but I thought that to change the members permanantly you had to pass the class by ref. That is the first issue. The second is the real mind boggler, and frustrator. In the OptionsForm, I have a variable that is global and is initialized in the constructor to the transpCol variable. this.transpColor= transpCol; Later in the Form I set this.transpColor to a color value, which should change the value of the variable passed in the constructor, but it does not! However, if, in the constructor I change the value this.transpColor= Color.Black; it does change the color of the variable passed! Am I not understanding something? Here is the top part of OptionsForm: public class OptionsForm : System.Windows.Forms.Form { public Color transpColor= Color.Empty; private System.ComponentModel.Container components = null; public OptionsForm(a.graphics.DrawingSurface ds, ref Color transpCol) { InitializeComponent(); this.transpColor= transpCol; }
  13. Are you going to post the code?
  14. Also, why are you using g.Clear(System.Drawing.SystemColors.Control)? When you paint in OnPaint, the only thing that will remain on the control is what you paint in each OnPaint event, everything else is reset, or erased.
  15. You need to paint with the Graphics from OnPaint, not FromHandle. e.Graphics. You don't need that code in Load, just leave it in the constructor. Also include: Me.SetStyle(ControlStyles.UserPaint, True)
  16. You can't, those are .net classes and methods; you can't add or take away from any class in .net (ie Graphics class). Just do it the way you are doing it.
  17. Make you own picturebox inheriting from UserControl and call SetStyle in the contructor to set up DoubleBuffing. Look up DoubleBuffer in search and you will find many posts about this.
  18. It supports many image formats if that is what you are asking.
  19. To me, this is a .net but: "the icon tray remains in the task bar" You must make the icon Visible property false before you close the form.
  20. Thanks divil, I'll look into it.
  21. I was hoping that wasn't the only solution. I didn't want to lose visual support. But I'll deal with it. Thanks guys.
  22. I'm not using control arrays. Maybe you glanced at the () and thought that was VB syntax not C#. Here is a better example: MyListBox lb=new MyListBox("Sending this string to new instance"); This is the way the designer seems to want it: MyListBox lb=new MyListBox(); But I need a way to send something to the new instance of the control. If I just need to rough it out without the designer, than so be it.
  23. My mistake, you meant updating the control when the file is edited.
×
×
  • Create New...