   Loading image
  Hello all!I created my own class to load and display an image in my window. I can create a new object from this class, load an image into memory and display it using the following functions from my main.cpp file (Im using vc++ 6 by the way). My problem is, other than not really knowing whats happening behind the scenes, is that I've read alot about freeing up the memory at certain points or at the latest when you shut down your program, but I dont know if I am doing it right or not. Any help would be greatly appreciated.//show a dudeif (key == 1){Dude dude1;dude1.LoadDude(hinstance,0);dude1.DrawDude(hdc,0,10,100);}THIS IS MY DUDE.h HEADER FILE:#ifndef DUDE_H #define DUDE_H#pragma onceclass DUDE{public:int mTRed;int mTBlue;int mTGreen;int mTYellow;int mTPurple;int mTBlack;int mTWhite;int mTGray;HBITMAP Bitmap[8];//DUDE Class PrototypesDUDE(); //Create a constructorvoid LoadDUDE(HINSTANCE hInstance, int Color);void DrawDUDE(HDC hdc,int Color, int x, int y);//void DeleteDUDE();};//constructorDUDE::DUDE(){mTRed = 0;mTBlue = 1;mTGreen = 2;mTYellow = 3;mTPurple = 4;mTBlack = 5;mTWhite = 6;mTGray = 7;}//this will load a DUDE in memoryvoid DUDE::LoadDUDE(HINSTANCE hInstance,int Color){if (Color == 0) Bitmap[0]= (HBITMAP)LoadImage(hInstance,"redDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 1) Bitmap[1]= (HBITMAP)LoadImage(hInstance,"blueDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 2) Bitmap[2]= (HBITMAP)LoadImage(hInstance,"greenDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 3) Bitmap[3]= (HBITMAP)LoadImage(hInstance,"yellowDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 4) Bitmap[4]= (HBITMAP)LoadImage(hInstance,"purpleDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 5) Bitmap[5]= (HBITMAP)LoadImage(hInstance,"blackDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 6) Bitmap[6]= (HBITMAP)LoadImage(hInstance,"whiteDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);if (Color == 7) Bitmap[7]= (HBITMAP)LoadImage(hInstance,"grayDUDE.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);}//this will draw the DUDE at the coords specifiedvoid DUDE::DrawDUDE(HDC hdc,int Color, int x, int y){for (int i=0;i<8; ++i){if (i == Color){HDC image_dc = CreateCompatibleDC(hdc);HBITMAP old_hbitmap = (HBITMAP)SelectObject(image_dc,Bitmap);BitBlt(hdc,x,y,320,192,image_dc,0,0,SRCCOPY);DeleteDC(image_dc);DeleteObject(old_hbitmap);}}}#endif