|
| ||||||||||
| Tags: code, constructor, png, programming, stack, visual studio 2010 |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Several PNG files stacking under windows forms
|
|
#2
| ||||
| ||||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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);
} 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"); |
|
#5
| |||
| |||
| 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
| |||
| |||
| 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
| |||
| |||
| 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
| |||
| |||
| 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); |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Several PNG files stacking under windows forms" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Stacking Game does not run | Xylander | Video Games | 8 | 13-03-2012 10:44 PM |
| Is stacking available on PSN and XBLA? | Udi-Baba | Video Games | 4 | 13-03-2012 06:34 PM |
| Stacking game is available on sale for 600 MSP | Hard.Kaur | Video Games | 4 | 13-03-2012 06:32 PM |
| How to Design a Windows Forms Application in VB.NET? | Deabelos | Software Development | 5 | 29-01-2010 09:23 PM |
| Windows Forms and opening MS Project.mpp File | jaksel | Software Development | 2 | 03-09-2008 08:53 PM |