Sign in to follow this  
n4gix

Map with GDI+ or something

Recommended Posts

Hello I need to do a Map where I can reload an image (.bmp) any time I would want to, so does anyone know about a tutorial for this??thank u in advance!!Rafa

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

The "guide" for GDI+ programming for many of us has been, "Graphics Programming with GDI+" by Mahesh Chand, but beware, it gives examples in C#. For the most part this is not a problem if you are a c++ programmer, but from time to time you may need to consult MSDN.

Share this post


Link to post
Share on other sites

Hi!!Thanks for ur help!!!, I wrote this post 'cuz I've been trying to get some decent manual for this, and I've been getting pieces of things. The problem is that Macros are made in ANSI C and GDI+ is for C++ so tht's the first thing mixed this 2 languages, but I think that is not a problem the main thing is that for example to get a handler to draw an image into a gauge it's kind of complicated, I will buy that book! and see what can I do !! but still if anyone haa something (ANYTHING) please let me know!Rafa

Share this post


Link to post
Share on other sites

You are correct, you will first have to learn how to setup your Gauge or Multi-gauge to be able to compile some files in C and others in C++. The SDK example is in C, and will be of little help if you are not an experienced programmer.If you are not an experienced C++ programmer, I would recommend looking at someone else's code to help you figure it out. One that is easily available is Arne's traffic radar gauge, which I believe you can find here at AVSIM.Basically, it is rather involved as you have to split things into two headers... one that is C compliant, and the other for your C++ stuff, or you have to use conditional compilation.I find the first approach cleaner the way I have things setup, and have no need for conditional compilation. Save your self a headache and comment the C headers at the top // Only ANSI C stuff hereso you don't forget and stick stuff in there like includes which include classes.Good luck

Share this post


Link to post
Share on other sites

Thank you Patrick, I'll try to work it out! and let u know about what I have found!.Rafa

Share this post


Link to post
Share on other sites

Ok Patrick, first let me tell you that I know a little bit of c++ but even if i would know a lot of things i think i would never take off my "dummie" title 'cuz we learn things every single day!! hehe.Well, can u explain this more for me "Basically, it is rather involved as you have to split things into two headers... one that is C compliant, and the other for your C++ stuff"'cuz I just added some #include's and functions to the files im using to make the gauge (which i already have working with MAKE_ICON and MAKE_STATIC from a sample i found. I use this --> Bitmap bitmap(L"respicture.bmp"); to try to make the var for the bitmap, then I need a handler here ---> //Graphics graphics(Handle); Graphics bmp_graphics(&NEED A HANDLER);so I can load the .bmp, so what do u think??Rafa

Share this post


Link to post
Share on other sites

Write to me at n4gix@comcast.net and I'll send you GDI Project Template.zip which is a sample project layout for GDI+ development.This was developed on the MSVC++ .NET 2003 IDE, so if you cannot load the .sln (Solution) in whatever you use, all the files are there for you to construct your own project solution. Simply add "gdiplus.lib" to your Linker.It is a trivial example of a basic GDI+ project, and will illustrate how to use GDI+ to create a simple "engine power display," using a 'wedge" that is rotated around the center axis according to the throttle lever's movement, producing a "circular fan" type of digital display... ;)

Share this post


Link to post
Share on other sites

Hi!, i've been working all the weekend with the files u sent. I made all that says there with my gauge, but still cannot load the .bmp I want to load. I'm using something like this:- Bitmap bitmap(L"aslink.bmp");But i think thats like a reference, isnt it??I have a tutorial for GDI+ which says this:// load the bitmap from a file bitmap_.reset( new gdp::Bitmap(fname.c_bstr()) );but when I use that it says that my GdiPlus doesnt have that method (reset), and I cannot use a var of type WSTRING.So anyone has a clue of this??, just load a bmpThank you

Share this post


Link to post
Share on other sites

Here is how I load a bitmap from resources:In my project's .h file... Image *rtu_base_bitmap = NULL; HINSTANCE gaugeInstance = 0; /////////////////////////////////////////////////////////////////////////////// RTU Controller Bitmaps/////////////////////////////////////////////////////////////////////////////#define RTU_Text 0x1000In my project's .rc file -RTU_Text BITMAP DISCARDABLE "resXLS_RTU_Text.BMP"In my gauge's .cpp file - case PANEL_SERVICE_PRE_INSTALL: if (!gaugeInstance) gaugeInstance = GetModuleHandle("Honeywell_RTU.gau"); // Windows API call if (gaugeInstance && !rtu_base_bitmap) rtu_base_bitmap = new Bitmap(gaugeInstance, (WCHAR*)MAKEINTRESOURCE(RTU_Text)); // GDI+ call break;Now, anytime I need to use the bitmap, I can refer to it as rtu_base_bitmap: { Rect destinationRect(0, 0, 400, 500); graphics.DrawImage(rtu_base_bitmap,destinationRect,0, 0, 400, 500, UnitPixel); }

Share this post


Link to post
Share on other sites

Hi! thank you! but what if I want to load another .bmp image whereas Im flying, i mean like a map!, understand?.Im asking 'cuz with .rc the .gau file compiles everything, so I need to load another thing, is that possible??thank you Bill

Share this post


Link to post
Share on other sites

>Hi! thank you! but what if I want to load another .bmp image>whereas Im flying, i mean like a map!, understand?.>>Im asking 'cuz with .rc the .gau file compiles everything, so>I need to load another thing, is that possible??It probably is possible, but I sure don't know how! ;)

Share this post


Link to post
Share on other sites

Hi!!! I could load the picture!!, it works!! thank you!:DI will find out the next step and will tell what did i do!Rafa

Share this post


Link to post
Share on other sites

>It probably is possible, but I sure don't know how! ;)Rats! I knew how but had forgotten it since I haven't used it in over a year... ;)Bitmap *MyImage;MyImage = Bitmap::FromFile(L"aircraftMyAircrafttextureMyImage.bmp"); RectF destination(0.0f, 0.0f, 394.0f, 91.0f); graphics.DrawImage(MyImage, destination);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this