CreateBitmap API 
Author Message
 CreateBitmap API

Hi everyone,
I've a big problem in using the API CreateBitmap. First here is my small
sample code:

ReDim BitmapData(83) As String
Dim c As Integer
Dim hCompDC As Integer
Dim hObject As Integer
Dim hselObject As Integer
Dim Res As Integer

For c = 0 To 83
    BitmapData(c) = Chr$(0)
Next c

hCompDC = CreateCompatibleDC%(picture1.hDC)
hObject = CreateBitmap%(32, 21, 1, 1, BitmapData(0))
hselObject = SelectObject%(hCompDC, hObject)
Res% = StretchBlt%(picture1.hDC, 0, 0, 64, 42, hCompDC, 0, 0, 32, 21,
SRCCOPY)
Res% = DeleteDC(hCompDC)
Res% = DeleteObject(hObject)

When I started this code I expected a small black rectangle in my picture
box. But within the rectangle appeared some white pixel (?). When I checked
the Bitmap, I found out, that the first wrong pixel is bit no. 14 the next
24, 30,40,46 etc.. So can anybody tell me what I'm doing wrong?

Thanks in advanced
Markus



Tue, 25 Apr 2000 03:00:00 GMT  
 CreateBitmap API

Hi all,


Quote:
> Hi everyone,
> I've a big problem in using the API CreateBitmap. First here is my small
> sample code:

> ReDim BitmapData(83) As String
> Dim c As Integer
> Dim hCompDC As Integer
> Dim hObject As Integer
> Dim hselObject As Integer
> Dim Res As Integer

> For c = 0 To 83
>     BitmapData(c) = Chr$(0)
> Next c

> hCompDC = CreateCompatibleDC%(picture1.hDC)
> hObject = CreateBitmap%(32, 21, 1, 1, BitmapData(0))
> hselObject = SelectObject%(hCompDC, hObject)
> Res% = StretchBlt%(picture1.hDC, 0, 0, 64, 42, hCompDC, 0, 0, 32, 21,
> SRCCOPY)
> Res% = DeleteDC(hCompDC)
> Res% = DeleteObject(hObject)

> When I started this code I expected a small black rectangle in my picture
> box. But within the rectangle appeared some white pixel (?). When I checked
> the Bitmap, I found out, that the first wrong pixel is bit no. 14 the next
> 24, 30,40,46 etc.. So can anybody tell me what I'm doing wrong?

Shouldn't you be using type Byte for BitmapData? Strings are stored in
unicode format (at least in VB5) and maybe that's messing things up a bit.

Regards:

David

     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     David Porter,  Computation undergraduate,  Wadham College,  Oxford



Wed, 26 Apr 2000 03:00:00 GMT  
 CreateBitmap API

The only thing unusual I see in your code is the string array.  Why not try
just using a regular string variable?  (I assume you're using 16-bit VB:
otherwise you should use a Byte array).

Instead of BitmapData(83) As String, try

Dim BitMapData As String
BitMapData = Space(84)

I have no idea if this is going to solve your problem, though.  It may be
something in the StretchBlt().  Try out some of the other settings via
SetStretchBltMode().

Jim Deutch
MS Dev MVP



Quote:
> Hi everyone,
> I've a big problem in using the API CreateBitmap. First here is my small
> sample code:

> ReDim BitmapData(83) As String
> Dim c As Integer
> Dim hCompDC As Integer
> Dim hObject As Integer
> Dim hselObject As Integer
> Dim Res As Integer

> For c = 0 To 83
>     BitmapData(c) = Chr$(0)
> Next c

> hCompDC = CreateCompatibleDC%(picture1.hDC)
> hObject = CreateBitmap%(32, 21, 1, 1, BitmapData(0))
> hselObject = SelectObject%(hCompDC, hObject)
> Res% = StretchBlt%(picture1.hDC, 0, 0, 64, 42, hCompDC, 0, 0, 32, 21,
> SRCCOPY)
> Res% = DeleteDC(hCompDC)
> Res% = DeleteObject(hObject)

> When I started this code I expected a small black rectangle in my picture
> box. But within the rectangle appeared some white pixel (?). When I
checked
> the Bitmap, I found out, that the first wrong pixel is bit no. 14 the
next
> 24, 30,40,46 etc.. So can anybody tell me what I'm doing wrong?

> Thanks in advanced
> Markus



Fri, 28 Apr 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CreateBitmap API

2. Problem with CreateBitmap API

3. CreateBitmap()

4. Bad DLL Calling Convention during CreateBitmap()

5. How to use CreateBitmap

6. How to use CreateBitmap?

7. Help! CreateBitMap Failure

8. Help! CreateBitMap Failure

9. Help! WinAPI function CreateBitMap Failure

10. CreateBitmap and VB 5.0 - ???

11. API API API

12. API, API, Who's got the API

 

 
Powered by phpBB® Forum Software