📄 wpw_wapi_bitmap_95.html
字号:
<HTML>
<HR><A NAME=WINAPI_BITMAP_WRONG_COLOR>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Wrong Color in Bitmap</H4><PRE>
In article <1995Jun19.165827.132541@mswe.dnet.ms.philips.nl>, jjanssen@mswe.dnet.ms.philips.nl (John Janssen) writes...
>I have a problem in showing a dib in my window:
>I do not get the correct colors!
>
>I know that it has something to do with converting the
>dib to a dev.dependent bitmap or such, but I cannot work
>it out from the Petzold book (I have problems with the more
>complex English sentences, as I am not English).
>
>What I want to do is:
>- Read the bitmap (I use the Petzold functions for this)
>- Display a specific part of the dib 1:1 in my window.
>
>It should work on 256 color and 24 bit video cards,
>and in windows 3.1 (and later on in windows 95).
>I am programming in C, using Borland.
>
>Can you please help me?
>Just the functions in the correct order will do.
>
>Thanks,
>
>John
>--
What you need to do is create a palette and then realize it so it is
transferred to the system palette. See Palette's under the SDK. The
problem is that Windows will map the colors of your bitmap to the available
colors in the system palette. So what you have to do is create your own
palette and use the functions SelectPalette and RealizePalette to add you
colors to the system palette. This is fairly well explained in the SDK but
I couldn't find it in Petzold.
Kevin Stultz
>--------------------------uuu----U----uuu------------------------------
<HR>
In article <1995Jun19.165827.132541@mswe.dnet.ms.philips.nl> jjanssen@mswe.dnet.ms.philips.nl (John Janssen) writes:
>I have a problem in showing a dib in my window:
>I do not get the correct colors!
>
>I know that it has something to do with converting the
>dib to a dev.dependent bitmap or such, but I cannot work
>it out from the Petzold book (I have problems with the more
>complex English sentences, as I am not English).
>
>What I want to do is:
>- Read the bitmap (I use the Petzold functions for this)
>- Display a specific part of the dib 1:1 in my window.
>
>It should work on 256 color and 24 bit video cards,
>and in windows 3.1 (and later on in windows 95).
>I am programming in C, using Borland.
>
>Can you please help me?
>Just the functions in the correct order will do.
I can recommend the following files from ftp.microsoft.com:
softlib/mslfiles/wincap.exe (dibapi.dll)
softlib/mslfiles/pw0775.exe (tutorial)
Are you doing the correct SelectPalette() & RealizePalette()?
--
John A. Grant jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
</PRE>
<HR><A NAME=WINAPI_BITMAP_TILING>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Tiling Bitmap in Windows Screen</H4><PRE>
I need to tile a bitmap on the entire background of a setup
installation screen. Can anyone give a general idea of how
tiling a small 32x32 bitmapp across a 1024 x 768 window might
work or
a pointer to an FAQ or good book with info.
Thanks
<HR>
Here is the code I use for 16 color bitmaps.
void TextureScreen(CWnd* pWnd, CDC* pDC, CBitmap& Texture)
{
CRect rect;
pWnd->GetClientRect(rect);
BITMAP bm;
Texture.GetObject(sizeof(BITMAP), (LPSTR)&bm);
// Tile screen with texture
CDC DCMem;
DCMem.CreateCompatibleDC(NULL);
DCMem.SelectObject(&Texture);
int X=rect.left;
int Y=rect.top;
int nWidth=rect.Width();
int nHeight=rect.Height();
int nTileWidth=bm.bmWidth;
int nTileHeight=bm.bmHeight;
for(int i=0, j=0; j<((nHeight/nTileHeight)+1);)
{
pDC->BitBlt( X + i*nTileWidth, Y + j*nTileHeight,
X + (i+1)*nTileWidth, Y + (j+1)*nTileHeight,
&DCMem, 0, 0, SRCCOPY);
i++;
if(i > nWidth/nTileWidth)
{
i=0;
j++;
}
}
DCMem.DeleteDC();
Texture.DeleteObject();
}
<HR>
In article <3s97c7$n35@uuneo.neosoft.com> coder <coder@neosft.com> writes:
>I need to tile a bitmap on the entire background of a setup
>installation screen. Can anyone give a general idea of how
>tiling a small 32x32 bitmapp across a 1024 x 768 window might
>work or
>a pointer to an FAQ or good book with info.
>
>Thanks
If it was 8 X 8 only, you could just create a brush from the bitmap
and do Rectangle() with the brush. I believe Win32 allows you to
create brushes from larger bitmaps, so it should be dirt simple in
Win32, which is going to become the norm (unless of course, that
part of Win32, is one of the things that is 'broken' in Windows '95).
If you tile it with a whole bunch of BitBlt(), it may take a while.
Perhaps you want to BitBlt() it to memory first and then do a single
BitBlt(). Perhaps that's how the desktop is drawn.
--
John A. Grant jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
</PRE>
<HR><A NAME=WINAPI_BITMAP_SHARING_IN_DLL>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Sharing bitmaps and cursors between Instances of an App</H4><PRE>
In article <3sghgk$47f@eng_ser1.erg.cuhk.hk> cfng@ee.cuhk.hk (Ng_Chi_Fai) writes:
>Hello all,
> In my application, I have a lot of bitmaps and cursors, I want to
>share them between differnet instances of my application, ie. keep only one
>copy of each resource in memory.
> If not, my application will easily eat up all the system resources.
> Would any one please tell me how to do that?
> Thanks.
Perhaps a DLL can be used to load them up & release them when
the last copy of the app dies. Usually, you have to go out of
your way to keep global data separate for each instance
that uses the DLL. In your case, this shared global is exactly
what you want.
You app can call LoadData() when it starts up and UnloadData() when
it exits. In the DLL, LoadData() increments a counter, loading
the data if it is 0. The UnloadData() decrements the counter,
and when it reaches 0, it frees the resources, turns off the lights
and puts the cat out :)
--
John A. Grant jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
</PRE>
<HR><A NAME=WINAPI_COPYING_BITMAP>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: How to copy a bitmap?</H4><PRE>
In article <3ti8c5$oqd@GRAPEVINE.LCS.MIT.EDU>, bobs@spiff.gnu.ai.mit.edu
says...
>
>
>This is probably a stupid question. I hope to get some equally stupid...
>but useful... answers. :)
>
>OK, would anyone care to give me a hint regarding how to make a duplicate
>copy of a bitmap? The only way I've figured out how to do it is to make
>two memory device contexts and BitBlt() the bitmap between them. This
>seems to work but there must be a way that is faster. Any suggestions
>would be helpful.
Nope, that's pretty much it. You need to create another bitmap and
select it into the destination dc first though.
If it's a DIB you can just copy the memory block.
</PRE>
<HR><A NAME=WINAPI_GREY_BITMAP>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: How to grey out bitmap?</H4><PRE>
>Hi there,
>I have a color bitmap and an icon. I would like to produce a new bitmap based on the
>existion one. The new one should look like a 'grey'd one (looks like disnabled). Is
>there any tools to do that? What is the algorithm to do that in C?
>any information would be appreciated. Thanks in advance.
>--
>=====================================================================
>Leying Zhao ATI Technologies Inc. Phone: (905) 882-2600 ext 8532
>E-mail address: lzhao@atitech.ca
>=====================================================================
Leying:
You need to select a custom palette such that the image appears
greyed. If the image already uses an optimized 256 color palette, you could
just select the system palette ( which consists of 20 colors essentially ) and
you'll find the image to be quite grey. The other way I can think of is to
select the palette for the image, then manually increment through the palette
indices manipulating the colors. Remember that the standard grey for the
system is RGB ( 127, 127, 127 ) or somewhere thereabouts... So you could
go through the indices of the selected palette for the bitmap, increment or
decrement the RGB values of that position such that they are closer to the
above grey values, and then display the picture with that palette. You'll have
to experiment with the amount to shift the colors... but it should work...
Good Luck,
Brett H. Close
KU Dept of EECS
Lawrence, Kansas close@cs.ukans.edu
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -