在螢屏上使用TextOut輸出文字,會有灰度,一個字的顏色不一致,怎么能輸出沒有灰度的字?
uj5u.com熱心網友回復:
矢量字體在縮放時,它要做“平滑處理”,當然會產生一些“過渡色”。
你可以試試先輸出到一個“緩沖DC”中,然后進行二值化處理,再輸出到顯示的地方。
不過這樣可能會出現明顯的鋸齒,文字較小的可能失真也嚴重。
uj5u.com熱心網友回復:
影像方式直接顯示看uj5u.com熱心網友回復:
確定是在用GDI輸出嗎,GDI都是純色帶齒的,而且還會有背景色的問題,感覺你輸出了帶透明度的文字,調節一下顏色,看是RGB的還是ARGB的。
uj5u.com熱心網友回復:
VB 6.0Declare Function TextOutA Lib "gdi32" (ByVal hdc As Long, ByVal nXStart As Long, ByVal nYStart As Long, ByVal lpString As String, ByVal cchString As Long) As Long
直接對hdc操作的
TextOut frmPeerB.hdc, (iWidth - sTextSize.cx) / 2, 1, tmp_string, AskLength(tmp_string)
uj5u.com熱心網友回復:
frmPeerB.Font = "黑體"frmPeerB.FontSize = 20
frmPeerB.ForeColor = RGB(255, 255, 255)
tmp_string = "測驗"
uj5u.com熱心網友回復:
關閉控制面板里面與文字清晰度相關的配置?uj5u.com熱心網友回復:
用Form.Print或PictureBox.Printf代替?uj5u.com熱心網友回復:
也是有灰度的輸出
uj5u.com熱心網友回復:
比如:
WinXP下,我的電腦、屬性、高級、性能、設定、視覺效果、平滑螢屏字體邊緣 ?
uj5u.com熱心網友回復:
或者GDI+中,#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")
VOID OnPaint(HDC hdc) {
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
FontFamily fontFamily(L"宋體");
Font font(&fontFamily, 12, FontStyleRegular, UnitPixel);
PointF pointF1(30.0f, 60.0f),pointF2(230.0f, 60.0f);
SolidBrush solidBrush(Color(255, 0, 0, 255));
StringFormat stringFormat;
WCHAR testString[] = L"Hello034∠你好";
stringFormat.SetFormatFlags(StringFormatFlagsDirectionVertical);
graphics.SetSmoothingMode(SmoothingModeDefault);
graphics.DrawLine(&pen, 0, 0, 200, 100);
graphics.DrawEllipse(&pen, 10, 10, 190, 90);
graphics.SetTextRenderingHint(TextRenderingHintSystemDefault);
graphics.DrawString(testString, -1, &font, pointF1, &stringFormat, &solidBrush);
graphics.SetSmoothingMode(SmoothingModeHighQuality);
graphics.DrawLine(&pen, 200, 0, 400, 100);
graphics.DrawEllipse(&pen, 210, 10, 190, 90);
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
graphics.DrawString(testString, -1, &font, pointF2, &stringFormat, &solidBrush);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
HDC hdc;
PAINTSTRUCT ps;
switch(message) {
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) {
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("GettingStarted");
RegisterClass(&wndClass);
hWnd = CreateWindow(
TEXT("GettingStarted"), // window class name
TEXT("Getting Started"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GdiplusShutdown(gdiplusToken);
return 0;
}
uj5u.com熱心網友回復:
測驗了一下,作業系統的原因,不同的作業系統下會有不同的表現,這個麻煩大轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/68616.html
標籤:VB基礎類
