Okay, let me start with what I'm trying to do, and below is how I'm trying to do
it (but open to other ideas...this is just how the project has evolved to this
point.) I am opening images off of the harddrive -- these are floorplans. They
can be rather large. Interesting to know that a .tif file that is only 813kb
can be opened by a LEAD Control or by another image viewer and it's reported
size is approx 15000x10000. Big. Anyway, after I get this .tif file loaded
(via a LEAD control), I now know the width and height of the image. What I want
to do is to create another bitmap DC in memory that has a bitmap the same size,
and I'll draw various things onto this. It's normally outlining walls on the
floorplan. I then create a 2nd bitmapDC/bitmap in memory, and I immediately
blit in the source bitmap from the lead control. Works great, but because the
.tif image is 1 color, as far as I can tell, I have to convert my bitmaps to 16
bit color (I guess it doesn'thave to be 16 bit...but I want to be able to do let
the user choose many different colors on screen for outlining the
That's the problem. Now here's how I've been attempting (so close!) to solve
I open up the tif in the LEAD Control. I create a memory DC for the drawing
layer. I create a temporary compatible bitmap using that DC and I use the width
and height of the source image. I then use Mike D's Copy Bitmap module
) to copy
that temp bitmap to yet another bitmap, this time converting the bit depth to 16
bits. Then I delete the temp bitmap, and finally select the new bitmap into the
DC. The new bitmap and new DC have long values that are <> 0, so I'm assuming
that it works (and it looks like it does because I'm able to blit this one to
the screen after working on it and it displays correctly.
I then do the exact same process again for a 2nd memory DC and bitmap. It
doesn't work here.
lDC1 = CreateCompatibleDC(0&)
lTemp = CreateCompatibleBitmap(lDC1, lwidth, lheight)
lBM1 = Copybitmap(lTemp, cbmDIB, lwidth, lheight, 16) '<---
this is the line that it fails on. No errors, just lBM1 afte this line is 0,
which is bad.
lBM1OLD = SelectObject(lDC1, lBM1)
Is this a memory problem? just not enough available? If anyone cares, I've
traced through Mike's CopyBitmap function and this line: "hDstBMP =
CreateDIBSection(hDstDC, DIBInf, DIB_RGB_COLORS, 0&, 0&, 0&)" on line 145 of
this file: http://www.yqcomputer.com/
is the one that I think fails. The 2nd time. The reason I think it fails is
because hDstBMP is 0 after this line instead of a handle to a valid
bitmap/DIBSection or whatever.
So, am I just trying to do too much in memory? Is there an alternate method I
should use? Am I doing something incredibly wrong with Mike's Code?
Any and all advice appreciated.