Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

help creating a bitmap tiler

Posted on 2000-05-08
5
Medium Priority
?
311 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

618 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