After running uniq on this file the output is unchanged.
"Celebrity Countdown" (1998) mathematics
"Celebrity Countdown" (1998) mathematics
"Celebrity Countdown" (1998) non-fiction
"Celebrity Countdown" (1998) non-fiction
"Celebrity Countdown" (1998) quiz-show
"Celebrity Countdown" (1998) quiz-show
"Celebrity Countdown" (1998) word-game
"Celebrity Countdown" (1998) word-game
Related
My goal is to have a fullscreen overlaying invisible "canvas" on which I can draw using win32's various drawing functions.
The way I am currently attempting it is this:
WNDCLASSA myclass = { 0 };
myclass.lpfnWndProc = WindowProc3;
myclass.hInstance = GetModuleHandle(0);
myclass.lpszClassName = "MyCanvas";
myclass.hbrBackground = CreateSolidBrush(0xFEEDBEEF);
myclass.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassA(&myclass);
...
HWND wnd = CreateWindowExA(WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TRANSPARENT, "MyCanvas", 0, WS_POPUP | WS_VISIBLE, 0, 0, screen_width, screen_height, 0, 0, GetModuleHandle(0), 0);
SetLayeredWindowAttributes(wnd, 0xFEEDBEEF, 0, LWA_COLORKEY);
Although this serves as a canvas, hours of googling later, I am still unable to draw on it semitransparently.
I have added a screenshot of what my program is currently displaying as I am writing this. What I would like to be able to do is, for example, make the black box in the top right corner (drawn with Rectangle) semitransparent so as to reveal the stackoverflow page content below it.
This is a question I found that I was hopeful about, but the resulting text is just a blended combination of the background color ((COLORREF)0xFEEDBEEF) and text color. Other things I have found have either just made the element fully invisible, done nothing at all, or required some library like MFC. I want to only use win32 functions if at all possible, as I would like to be able to achieve the highest FPS possible.
I do not care if this doesn't work on all Windows versions as long as it does on 7 up to 10.
If you only need transparency for a rectangular area where all pixels either have the same transparency (aka alpha) value or are completely transparent, you can use SetLayeredWindowAttributes() with a combination of alpha value and/or color key.
UpdateLayeredWindow() is the way to go if you need to be able to define transparency per-pixel.
For that you have to create memory DC and select a 32bpp bitmap into it. You may use the buffered paint API to ease the task. Raymond Chen has a blog post with a code sample about that.
You can draw into the memory DC, but you can't use most of GDI API for that, because GDI ignores the alpha channel (transparency). I suggest using GDI+ which allows you to specify the alpha values.
After you have completed drawing into the memory DC, you would call UpdateLayeredWindow() and pass that memory DC as the argument for the hdcSrc parameter to make the result visible on screen.
Illustration of possible effects:
SetLayeredWindowAttributes( hwnd, 0, 176, LWA_ALPHA );
SetLayeredWindowAttributes( hwnd, colorkey, 0, LWA_COLORKEY );
SetLayeredWindowAttributes( hwnd, colorkey, 176, LWA_ALPHA|LWA_COLORKEY );
UpdateLayeredWindow( ... )
Note the antialiased edge of the shape and the transparency gradient in the last example. Things like that are only possible with UpdateLayeredWindow().
I am trying to draw a multiline text using drawText.
I am able to keep the width constant by passing DT_WORD_ELLIPSIS | DT_WORDBREAK flags
but if the string is long the text is getting cut vertically in the last line.
How to ensure that drawText doesn't draw the last line if it it can't fit the whole height ?
Currently I am passing these flags to drawText - DT_NOPREFIX | DT_WORD_ELLIPSIS | DT_LEFT | DT_WORDBREAK | DT_EXTERNALLEADING
Specify the DT_EDITCONTROL flag. According to the MSDN documentation:
DT_EDITCONTROL
Duplicates the text-displaying characteristics of a multiline edit
control. Specifically, the average character width is calculated in
the same manner as for an edit control, and the function does not
display a partially visible last line.
So I'm trying to using CreateFont to try to create a font similar to the one I have in Photoshop, but if you look close the quality in Photoshop is a lot better.
Here's the code I'm using to create the font:
CreateFont(45, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_MODERN, __T("Times New Roman"));
And here is a comparison of the two fonts:
As you can see the top one is much smoother.
Should I be using different arguments in CreateFont? I'll admit I don't completely understand them all.
An explanation would be nice.
Photoshop uses its own antialiasing and applies it consistently.
Windows only uses antialiasing on font sizes within certain limits, and it looks like your sample is outside the limits. Here's a quote from the CreateFont documentation (emphasis added):
ANTIALIASED_QUALITY Font is antialiased, or smoothed, if the font supports it and the size of the font is not too small or too large.
You might have better control in GDI+.
I was reading this article of codeproject.
and I would like to achieve the same fog text effect using gdi or gdi+. I am not concered about the scrolling and other features of this article, just the ability of apply a fog effect to the end of a text string
// Draws fog effect with help of gradient brush with alpha colors.
using (Brush br = new LinearGradientBrush(new Point(0, 0), new Point(0, this.Height),
Color.FromArgb(255, this.BackColor), Color.FromArgb(0, this.BackColor)))
{
e.Graphics.FillRectangle(br, this.ClientRectangle);
}
What are you after exactly - the example you gave already is gdi+.
If you want to apply a fog effect (gradient) to a line of text. First measure the bounding rect of the text, then create the brush to fit this rect and apply it above the text, or just use the brush to draw the text. If this is what you're after say so and I'll dig up some code.
So, I have a screen capture utility (it takes full screen shots and saves it to png files) I've written, and it uses SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN to determine the width and height of the desktop.
I then get the desktop DC and copy out the bits and save them as png.
BitBlt(
backDC, 0, 0,
backBufferCX, backBufferCX,
desktopDC, X_SRC, 0, SRCCOPY );
Here X_SRC is usually 0, UNLESS THE DESKTOP HAS BEEN EXTENDED "TO THE LEFT". In that case it needs to be -1280px, for example, if the left monitor measures 1280px.
How can I determine if the desktop's starting point is negative (if the user has extended his desktop to the left?)
You can obtain the positioning information for all of the monitors via the EnumDisplayMonitors method.
Or, if you only care about the corners of the virtual screen, you can pass SM_XVIRTUALSCREEN and SM_YVIRTUALSCREEN into the GetSystemMetrics method.
You should use GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN) as the x, y coordinates to BitBlt