 |
|
 |
Can any body help me write a Edit Box of thing which can be rotated at any arbitrary angle,with any font with cut/copy/paste functionalities? Thanks in advance. I m trying with region/ SetWorldTransform API's but finding it difficult to display a caret at correct location. Am I going right way??
REGARDS
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
please, tell me, in your function "CreateRgnFromFile" why did you allocate with "+8" in the follwing line:
LPBITMAPINFO bi = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFO) + 8];
and "+4" in: LPBYTE pBits = new BYTE[bi->bmiHeader.biSizeImage + 4];
thanks, rioan
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Damn, it was 3 years ago... I can't believe it...
LPBITMAPINFO bi = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFO) + 8];
DIB_RGB_COLORS in the second call of the GetDIBits means that (from MSDN) "The color table should consist of literal red, green, blue (RGB) values.", which means three RGBQUADs (4 bytes each one), in BITMAPINFO we have one, so we need to two more. (better to write 2 * sizeof(RGBQUAD) instead of 8).
LPBYTE pBits = new BYTE[bi->bmiHeader.biSizeImage + 4]; Actually , here should be 2, not 4. It's required for 16- and 24-bit color values. Let's say, we are working with 24-bit image and pColor points to the last 3 bytes in the buffer, here (*(LPDWORD)pColor & 0x00FFFFFF) we access one byte out of buffer, and cut it by 0x00FFFFFF, for 16-bit image we will access two bytes out of buffer. That was made just to prevent read access violation of these bytes and make some codereview programs like boundschecker to be happy. 
I've changed my email and lost the password, so I can't modify the article, and I think in my case, administrator would not help me.:(
Thanks for the interest, happy programming.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I use this tehnique for a custom control (child of a frame), derived from CStatic and displaying a Bitmap.
In this context you have to set WS_CLIPSIBLINGS flag to the control.
Maybe this helps somebody. 
BTW: GREAT ARTICLE !!!
adrian
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
I remember looking at the SetWindowRgn() function years ago and thinking it was an awful complicated thing. Never really grasped the documentation for the function.
Your example has helped me do something that I have been saying "I dunno how to do that..." for a while now. And it was very easy to plop into my silly little program.
Thanks a whole lot. 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I have an application that draws bitmaps. I added on the fly transparency via a mask. I wanted to also create a region that would:
1) Let me highlight the VISIBLE portions of the bitmap using FrameRgn 2) Allow me to detect if my mouse is over the visible portion of the bitmap (PtInRegion)
This code seems almost what I need, however, I'm stretchblt'ing my source and mask together to create the transparency - so where to I need to create the region? With every redraw? Would that be too resource hungry?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
this is excellent, I've looked at about 4 or 5 classes that do just this, and yours works the best by far...
other classes would load slowly, or require dll's, this is very smooth and nice
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
This works great for me under 95/98/ME/NT/2000/XP under all resolutions and color depths that I've tested (640x480 up through 1280x1024 from 256 color through 32 bit). However, the killer problem is Large Fonts. I don't personally use large fonts but someone here does and pointed it out to me. I have a dialog with 4 buttons on it and it drops all 4 buttons severly down and to the left of where they should be. Any ideas how to deal with this?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
Its an excellent piece of code.
Is it possible to do the reverse of this utility i.e. convert a region into a bitmap file. I am writing a remote desktop viewer app and in need of such a functionality wherein I have to store the updated Client region (returned by GetUpdateRgn API function)in to a bitmap file and planning to send it over the n/w. And yes Im using pure win32 SDK code (no MFC) for achieveing this. Can you help me out.
all help appreciated
keep the faith
Deepesh S Gujarathi
|
| Sign In·View Thread·PermaLink | 1.86/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
hi everybody !
as you can see, this code doesn't work in 16bit, so change the following code :
// swap red and blue components BYTE tmp = pClr[0]; pClr[0] = pClr[2]; pClr[2] = tmp; // convert color if curent DC is 16-bit (5:6:5) or 15-bit (5:5:5) if ( bih.biBitCount == 16 ) { color = ((DWORD)(pClr[0] & 0xf8) >> 3) | // 3 ((DWORD)(pClr[1] & 0xf8) << 3) | // 2 ((DWORD)(pClr[2] & 0xf8) << 8); // 7 }
by
// swap red and blue components // DON'T NEED TO SWAP ANY COLOR !!!! //BYTE tmp = pClr[0]; pClr[0] = pClr[2]; pClr[2] = tmp; // convert color if curent DC is 16-bit (5:6:5) or 15-bit (5:5:5) if ( bih.biBitCount == 16 ) { pClr[0] = pClr[0] & 0x1F; pClr[1] = pClr[1] & 0x3F; pClr[2] = pClr[2] & 0x1F;
color = (DWORD)((pClr[0]<<(5+6))|(pClr[1]<<5)|pClr[2]); }
that all ! bye !

F.Julien
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
works but not for white as transparent color. anybody else seen this? does anybody know how to fix this?
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
[1]. First question.. The 16bit color has a 5-5-5 or 5-6-5 RGB setting. but i don't know which functions get a 5-5-5 or 5-6-5 mode in the VGA card. if anyone know how to work these, mail to me.....
// convert color if curent DC is 16-bit (5:6:5) or 15-bit (5:5:5) if ( bih.biBitCount == 16 ) { // [1]. these codes're very weirdy. => it does not work in my computer, // using win98. color = ((DWORD)(pClr[0] & 0xf8) >> 3) |// 3 ((DWORD)(pClr[1] & 0xf8) << 3) |// 2 ((DWORD)(pClr[2] & 0xf8) << 8); // 7
// [2]. if codes will be changed into a 5-5-5 or 5-6-5 mode. // [2-1]. any function gets a 5-5-5 or 5-6-5 mode in the VGA card. .... ( i don't know function...)
// [2-2]. if (5-5-5 bmp mode) color = ((DWORD)(pClr[0] & 0x1f) ) |// BLUE ((DWORD)(pClr[1] & 0x1f) << 5) |// GREEN ((DWORD)(pClr[2] & 0x1f) << 10);// RED
// [2-3]. if( 5-6-5 bmp mode) color = ((DWORD)(pClr[0] & 0x1f) ) |// BLUE ((DWORD)(pClr[1] & 0x1f) << 6) |// GREEN ((DWORD)(pClr[2] & 0x1f) << 11);// RED
}
=> what do u think?

From scwpark
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
This code works fine on 95, 98 and W2K but ExtCreateRegion always returns NULL on NT4. It appears that NT4 is fussy about the order in which the RECTs are presented and the other flavours on Windoze aren’t.
The code will work if the image is scanned in the reverse order.
Change the outer loop From: for ( i = 0; i < bm.bmHeight; i++ ) To: for ( i = bm.bmHeight-1; i >= 0; i-- )
Then the code will run on NT4.
I have not been able find any documentation on this quirk but it works for me. It’s probably just another deliberate trap that MS have set.
I hope that this saves some one from the headache that I went through.
Regards,
Martin
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
1) LoadImage as DDB is a bad idea, as color will be lost in 4-bpp, 8-bpp display mode.
2) bpp != bi.bmBitsPixel >> 3, as DDB could be multiple plane.
3) bi.bmWidth * bm.bmHeight * bpp, may not be enough memory, as DDB scanline should be WORD aligned.
4) pixel access is wrong, as DDB could be multiple plane.
5) CreateRectRgn resource leak, never deleted
6) CreateRectRgn and CombineRgn very slow, basically O(n^3) algorithm or worse
|
| Sign In·View Thread·PermaLink | 1.67/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
Actually, I can implement the sample and it seems that it succesfully works, but...
Where I put the mask color?? In the pPoint parameter? It says that it will get the pixel 0,0 if I introuduce NULL. But... The window succesfully redefines its size to the image, but... it's a rectangle!!
Or should I use 2 color bitmaps?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
nope... the coordinates you may give are the coordinates inside the image. Example:
(0,0) o-------------------+ | (15,10) | | o----+ | | | | | | +----+ | | | +-------------------+
in this image you have hole in the middle of the image. if you pass NULL in the point parameter it tries to use the color at the upper-left corner which isnt what you want. so in this case you give a coordinate inside the hole.. for example (16, 11)... and it works. so the code looks the mask color under the given pixel coordinates. of course you may change the function and change the position parameter to a COLOREF and use it as mask color.
--memon
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Everytime CreateRgn is called it's not being deleted. This results in resource leaks. If you use this code, be sure to delete resources
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
 |