?
Solved

help creating a bitmap tiler

Posted on 2000-05-08
5
Medium Priority
?
309 Views
Last Modified: 2008-02-01
 Hello everyone.  What I want to do is this:  create a program which takes a number of bitmaps, each having a name formatted as name0000, name0001, etc, and loads them one by one.  It then takes each of these bitmaps and tiles them into a grid with a 1 pixel border between each.  Then, saving would be a nice option but not necessary (I could just use printscreen).  I don't care if it uses a dialog or SDI or whatever.

  Unfortunately, I have pretty much no experience with HBITMAPS and the like, and I'm not sure how to get started.  I'd appreciate it if someone could get me started on the riight track.

Thanks a lot!
Gabe S.
0
Comment
Question by:GabeSmed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2791961
okay you can load the bitmaps from file using ::LoadImage()

you can get the size of the bitmap using ::GetObject() to fill in a supplied BITMAP structure

you can BitBlt the bitmap by selecting it into a device context and then BitBlt'ing it onto the screen

There are many examples on the above

Keywords are LoadImage, GetObject, BITMAP and BitBlt

If you need help on any of the steps please ask
0
 
LVL 1

Expert Comment

by:yz
ID: 2791972
I think there should be a easy way, at first create a large bitmap, and load it into a memory DC, fill it with the border color, then load these small bitmap file, and paste them into this large bitmap use bitblt at the correctly position.
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 600 total points
ID: 2795719
Next is small programm for display
bitmap to screen. Enumerate all bitmaps in you dir (FindFirstFile/FindNextFile),
make coordinates and use this programm
for each Bitmap for every coordinates :
void DisplayBitmap(HINSTANCE hInst,HDC hdc, char *szBitmapName, int x, int y)
{
  BITMAP bm;
  HDC hdc1 = CreateCompatibleDC(hdc);
  HBITMAP bmp = (HBITMAP)LoadImage(hInst, szBitmapName,IMAGE_BITMAP,
                                                   0,0,LR_LOADFROMFILE);
  GetObject(bmp,sizeof(bm),&bm);//get bitmap data
  SelectObject(hdc1, bmp);     //select
  BitBlt(hdc, x,y,bm.bmWidth,bm.bmHeight,
                 hdc1, 0, 0, SRCCOPY);  //display
  DeleteDC(hdc1); //delete context
  DeleteObject(bmp); //delete object
}

Of course, it is only 1-sr step in you
Apps.

I hope, it helps. Alex
0
 

Author Comment

by:GabeSmed
ID: 2797844
That's a great answer, but I have one (two) questions.  How do I supply the HINSTANCE and HDC in the parameters?

Thanks.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2801636
That may be begin of you apps:
#define STRICT
#include <windows.h>
#pragma hdrstop
#include <windowsx.h>

LRESULT FAR PASCAL  WndProc( HWND, UINT , WPARAM, LPARAM );
HINSTANCE hInst;
#pragma argsused
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
          LPSTR lpszCmd, int nCmdShow)
{
   static char szAppName[] = "Bitmap" ;
   HWND        hwnd ;
   MSG         msg ;
   WNDCLASS    wndclass ;
//   HANDLE    hAccel;

   if (!hPrevInstance)
   {
      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
      wndclass.lpfnWndProc   = (WNDPROC)WndProc ;
      wndclass.cbClsExtra    = 0 ;
      wndclass.cbWndExtra    = 0 ;
      wndclass.hInstance     = hInstance ;
      wndclass.hIcon         = LoadIcon( NULL, IDI_APPLICATION );
      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
      wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
      wndclass.lpszMenuName  = MAKEINTRESOURCE( CHELPAPMENU );
      wndclass.lpszClassName = szAppName ;

      RegisterClass (&wndclass) ;
  }

  hInst = hInstance;//save instance
  hwnd = CreateWindow (szAppName,
    "Windows Help Example",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    NULL,
    NULL,
    hInstance,
    NULL) ;

   ShowWindow (hwnd, nCmdShow) ;
   UpdateWindow (hwnd) ;

   while (GetMessage (&msg, NULL, 0, 0))
   {
       TranslateMessage (&msg) ;
       DispatchMessage (&msg) ;
   }
   return msg.wParam ;
}

LRESULT FAR PASCAL  WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

   switch (message)
   {
      case WM_PAINT:
      {
        HDC hdc;
        PAINTSTRUCT ps;
        RECT rectClient;

        hdc = BeginPaint( hwnd, &ps );//get dc
       //paint with dc and hInstance
       //for find files use FinFirstFile...
        EndPaint( hwnd, &ps );
      }
      break;

      case CM_EXIT:
           DestroyWindow( hwnd );
           break;
      case WM_DESTROY:
         PostQuitMessage (0) ;
         return 0 ;
   }
   return DefWindowProc (hwnd, message, wParam, lParam) ;
}
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question