#### Archived

This topic is now archived and is closed to further replies.

# Structs for bitmaps

This topic is 6054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I copied some code from one function to another and now I get this- UCHAR blue = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 0]) >> 3, green = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 1]) >> 3, red = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 2]) >> 3; (585) : error C2228: left of '.buffer' must have class/struct/union type (586) : error C2228: left of '.buffer' must have class/struct/union type (587) : error C2228: left of '.buffer' must have class/struct/union type the bitmap struct was made outside of a function, if that makes any difference.
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path. Edited by - felisandria on February 21, 2002 10:36:08 AM

##### Share on other sites
Have you declared bitmap as a variable ?

IE.
  BITMAP bitmap;

A struct is just a type definition, used like ''int'' or ''char''.

,Jay

##### Share on other sites
quote:
Original post by Jason Zelos
Have you declared bitmap as a variable ?

IE.

  BITMAP bitmap;

A struct is just a type definition, used like ''int'' or ''char''.

,Jay

thats what I ment that I did! what''s an API?

the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

##### Share on other sites
quote:
Original post by PPCThug
what''s an API?

That game dictionary is actually useful for something!

quote:
Application Program Interface. A set of routines which acts as a go-between for the operating system and a program. For instance, DirectX is a Windows API.

##### Share on other sites
I think I'm with you, if you are defining blue I would use a macro like :

Blue = RGB (R, G, B)

in directX

if you want to shift bits and combine them, use a bitwise OR (| in C++ I think).

IE:

  DWORD Colour = ((bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 0]) >> 16)) | ((bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 1]) >> 8)| ((bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 2]));

Assuming dword is 32 bits (or at least 24) and each call returns and 8 bit value.

eg.
Red   = 11111111 >> 16 00000000 00000000 00000000 11111111Green = 11000000 >> 8  00000000 00000000 11000000 11111111Blue  = 00000011       00000000 00000011 11000000 11111111

,Jay

Edited by - Jason Zelos on February 20, 2002 6:00:19 PM

##### Share on other sites
I just saw your other post, this is the line that creates the pixel (16 bit format).

  USHORT pixel = _RGB16BIT565(red,green,blue);

The reason for the error, as near as I can make out is that you are defining bitmap in Game_Main() as a local variable and not in the function where you have moved your code to. Try copying that across too.

You will need to declare the other vars in the function as well.

,Jay

##### Share on other sites
actually that''s a small part of code that''s supposed to copy a bitmap into a directdraw surface. and I didn''t have a problem with it untill I moved it to a nother function.

the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

##### Share on other sites
  int Game_Main(){ if (iWindowClosed) return(0); if (KEYDOWN(VK_ESCAPE)) SendMessage(hwnd, WM_DESTROY,0,0); DDraw_Fill_Surface(lpddsback, erasecolor); if (FAILED(lpddsback->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) return(0); DDRAW_INIT_STRUCT(ddbltfx); if (FAILED(lpddsback->Blt(NULL, lpddsmmenu, NULL, DDBLT_WAIT, NULL))) return(0); if (FAILED(lpddsback->Unlock(NULL))) return(0); while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT))); return(1);} // end game main

I still don''t see anything in game main that the code would need.

MSVC++ 6.0 intro
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.

##### Share on other sites
Is the struct definition and the bitmap declaration global in the same module (.cpp file) as the new function. Could you include the code from the void NewFunction (void) { to the end }.

,Jay

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
632567
• Total Posts
3007113

×