Results 1 to 8 of 8

Thread: Several PNG files stacking under windows forms

  1. #1
    Join Date
    May 2011
    Posts
    1,938

    Several PNG files stacking under windows forms

    I enclose ready a PNG file beneath Level spirit, and the parts where the fluid is transparent (but still black lines since they include being at the top). It also prepares the image of air bubbles. Now I'm annoying to stack jointly in the shape and image of the bubble (Picture Box) is underneath the frame png (Picture Box, Image PNG, background Color transparent), on the other hand, can be seen in the transparent parts of the picture I can only observe the backdrop picture of the board (which will be images) there. Is there any method to make the image visible?

  2. #2
    Join Date
    May 2009
    Posts
    527

    Re: Several PNG files stacking under windows forms

    Create a bitmap private member variable and the file upload (or assign a resource), PNG background. Then use the charts: FromImage (Image ^) static method to get a Graphics instance that can be used to sketch the unique bitmap. I would create a confidential member variable, too. If painting, use the Graphics object to sketch a picture on the additional - the transparent areas are diverse (you can also change OnPaint (...)). Utilize one of the overloads of DrawImage (...). These functions also permit you to render and /or resize the image is developed, and can, for example, the use RotateTransform (float) - well, apply rotations.

    Make certain the images have the similar dpi resolution, as this will be able to from time to time produce unforeseen results. You will be able to utilize the bitmap: SetResolution (float, float) member function to change it, along with DpiY DpiX and properties of the instance of the Graphics class. You can now allocate the image in a straight line into the PictureBox and based on that, but this could create some flickering. Or perhaps you cannot pictureBox seem to remember that behave a modest strange when it comes to that. Just use a panel if there is any difficulty.)
    Code:
    Retrieves the BufferedGraphicsContext for the 
             // current application domain.
             context = BufferedGraphicsManager::Current;
    
             // Allocates a graphics buffer
             grafx = context->Allocate( bmpGraphics, Rectangle(0, 0, bmp->Width, bmp->Height) );

  3. #3
    Join Date
    Apr 2009
    Posts
    491

    Re: Several PNG files stacking under windows forms

    Since the bubble is always visible (note that I have the top view of the level) does not have to be below the frame. The only thing is that the black lines (indicators) must be of the bubble, for this I used the PictureBoxes with black backdrop and very small height. So I have the JPG with the frame in the backdrop (the bubble was detached in PS) on the board then the PNG picture of the bubble (and it will be curved up) and on peak of it I have two picture boxes with black lines, then I am energetically changing the site of the picturebox with the bubble. And it workings quite nice and smoothly.

  4. #4
    Join Date
    May 2009
    Posts
    542

    Re: Several PNG files stacking under windows forms

    These are the event handlers doing the actual work:
    Code:
    // Form1.cpp
    
    #include "stdafx.h"
    
    #include "Form1.h"
    
    using namespace LayeredPNGs;
    
    System::Void Form1::trkX_Scroll(System::Object^  sender, System::EventArgs^  e)
    {
      int x = trkX->Value;
      lblX->Text = String::Format("x = {0}", x);
      ptOverlayPos.X = x;
      pbBack->Invalidate();
    }
    
    System::Void Form1::trkY_Scroll(System::Object^  sender, System::EventArgs^  e)
    {
      int y = trkY->Maximum - trkY->Value;
      lblY->Text = String::Format("y = {0}", y);
      ptOverlayPos.Y = y;
      pbBack->Invalidate();
    }
    
    System::Void Form1::pbBack_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e)
    {
      e->Graphics->DrawImage(bmpOverlay, ptOverlayPos);
    }
    The following is the constructor that sets up the form class:
    Code:
    public:
        Form1(void) : ptOverlayPos(0, 0)
        {
          InitializeComponent();
          //
          //TODO: Konstruktorcode hier hinzufügen.
          //
    
          /*
    
          // The following is meant to set up the Bitmap object from an image resource. Unfortunately
          // it tends to fail regularly (at least for me) due to the "vanishing resource problem".
    
          ComponentResourceManager ^cresm = gcnew ComponentResourceManager(Form1::typeid);
          Object ^objResource = cresm->GetObject("Overlay.png");
          Diagnostics::Trace::Assert(objResource != nullptr, "Overlay bitmap construction from resource failed");
          bmpOverlay = gcnew Bitmap(safe_cast<Drawing::Image ^>(objResource));
    
          */
    
          // This is the alternative way, constructing the Bitmap object from a disk file
          // (wouldn't really like that in a real-life app though):
    
          bmpOverlay = gcnew Bitmap("Overlay.png");
    A great deal of this code is really commented out, but I required showing it to you because that's the genuine way of creating the bitmap object. Disappear resource problem occurs whenever the slightest I can alter the form explain, all the resources that are physically added to Form1.resx vanish instantly. Would almost certainly have to put in a resx file in the project that is self-governing of form, but have not managed to do this. Maybe I'm too dumb to understand how to use this managed resource "editor" or just another weird limitation of the Express edition. In fact, I would really like either option.

  5. #5
    Join Date
    May 2011
    Posts
    451

    Re: Several PNG files stacking under windows forms

    What do you mean by "missing resource problem"?
    Anyway, I cannot run the project (visual studio 2010) but I've seen the set of laws and exhibit. In the unique difficulty that I required to demonstrate (say, in the example), 2 stars PNG one another, and I required them together, as healthy as the backdrop picture to be able to be seen all the time. If anybody is paying attention: I have uploaded screen shots of what I've done texture framework will be replaced once you get improved pictures.

  6. #6
    Join Date
    Mar 2010
    Posts
    154

    Re: Several PNG files stacking under windows forms

    When I at first understand script that I consideration I'd exist on me to be confused (as if the lack of Intelligence Visual studio 2010, but with opposite sign). In this case it really would have been that I was too stupid to operate this aspect of the Visual Studio. Too bad this does not work well in my Visual studio 2010 Express. I had always tried to add the. Resx the Add New Item button in the toolbar and the dialog box that opens when you click it, simply does not offer the option of adding a. Resx. It would be actually astonished if the contextual menu item that act in a different way, and in fact does not. Your project compiles and runs with no troubles on my visual studio 2010, it seemed as if the managed resource editor to accept the existing file. Resx in my little test first. It makes me wonder if I could help if someone gives me a vacuum. resx file that I could simply copy my project and then add it as an existing item .It should be kept as long as usual tonight, because I have a large family celebration in the morning and started very early for my habits. I'll write a more comprehensive response to the morning after.

  7. #7
    Join Date
    May 2009
    Posts
    529

    Re: Several PNG files stacking under windows forms

    which is related. resx collapsed under the node in the way C + + / CLI. And is not normally used in so far as there usually is no need for the developer to work directly with him in any way. But it is very commonly used by Designer: Contains references to related resources such as background images of the forms or buttons, as used there in the thread moving button. It also contains information about objects placed in the tray of the designer (timers, for example), at least its position in the tray. It seems as if this could be the beginning of another interesting discussion, so I'll create a separate thread of it. I'll post the code that contains the class PentagramBox I said that as a basis for discussion. The thread that I wrote for about a month ago and the task is most likely already handed in.

  8. #8
    Join Date
    May 2009
    Posts
    546

    Re: Several PNG files stacking under windows forms

    complete code
    Code:
      // The following is meant to set up the Bitmap object from an image resource. Unfortunately
          // it tends to fail regularly (at least for me) due to the "vanishing resource problem".
    
          ComponentResourceManager ^cresm = gcnew ComponentResourceManager(Form1::typeid);
          Object ^objResource = cresm->GetObject("Overlay.png");
          Diagnostics::Trace::Assert(objResource != nullptr, "Overlay bitmap construction from resource failed");
          bmpOverlay = gcnew Bitmap(safe_cast<Drawing::Image ^>(objResource));
    
          */
    
    // This is the alternative way, constructing the Bitmap object from a disk file
     // (wouldn't really like that in a real-life app though):
    
          bmpOverlay = gcnew Bitmap("Overlay.png");
        }
    		// INFO: To find out what the first parameter should be, right-click
    			// Resources.resx, choose Properties, expand all, click on Command Line,
    			// copy the name of the .resources file (withouth the extension).
    			System::Resources::ResourceManager^ rmngr 
    				= gcnew System::Resources::ResourceManager("TheBubbleTest.Resuouces", 
    				this->GetType()->Assembly);

Similar Threads

  1. Stacking Game does not run
    By Xylander in forum Video Games
    Replies: 8
    Last Post: 13-03-2012, 10:44 PM
  2. Is stacking available on PSN and XBLA?
    By Udi-Baba in forum Video Games
    Replies: 4
    Last Post: 13-03-2012, 06:34 PM
  3. How to disable gamepad in Stacking?
    By Maq-Bool-Ji in forum Video Games
    Replies: 3
    Last Post: 12-03-2012, 11:58 PM
  4. How to Design a Windows Forms Application in VB.NET?
    By Deabelos in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 09:23 PM
  5. Windows Forms and opening MS Project.mpp File
    By jaksel in forum Software Development
    Replies: 2
    Last Post: 03-09-2008, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •