大家好,希望有人可以帮助我.
我在页面上有一系列照片,当您将鼠标悬停在页面上时,白色的效果渐渐消失,标题和说明会显示在其上方.
我遇到的问题是,如果我将鼠标悬停在文本区域上,则白色效果会再次淡出.这是一个奇怪的闪烁问题.
我需要它才能工作,这样无论你在哪里悬停在图像上,它总是保持着色,然而当它关闭时它又回到了正常的图像.
我正在努力学习编码,所以对我来说很光.我在其他帖子中发现了类似的问题,但无法确定他们的建议如何应用于我的代码.
我的代码如下.
$('div.project-image a img').mouseover(function() {
$('div.hover').css('filter', 'alpha(opacity=70)');
$('div.hover', $(this).parent().parent()).fadeIn(500);
});
$('div.hover').mouseout(function() {
$('div.hover').css('filter', 'alpha(opacity=70)');
$('div.hover', $(this).parent().parent()).fadeOut(500);
});
$('div.hover').bind('click', function(e) {
window.location = $(this).parent().children('a').attr('href');
Run Code Online (Sandbox Code Playgroud)
});
使用的CSS样式是:
#content div.project-image (styles the image area)
#content div.hover (displays the white tinted image)
#content div.hover h1 (styles the title)
#content div.hover p (styles the description)
Run Code Online (Sandbox Code Playgroud) 这就是我在条形图上显示的字符串:
public class ProgressBarWithText : ProgressBar
{
const int WmPaint = 15;
SizeF TextSize;
PointF TextPos;
public ProgressBarWithText()
{
this.DoubleBuffered = true;
this.TextChanged += ProgressBarWithText_TextChanged;
this.SizeChanged += ProgressBarWithText_SizeChanged;
}
public override string Text
{
get { return base.Text; }
set { base.Text = value; }
}
void RecalcTextPos()
{
if (string.IsNullOrEmpty(base.Text))
return;
using (var graphics = Graphics.FromHwnd(this.Handle))
{
TextSize = graphics.MeasureString(base.Text, this.Font);
TextPos.X = (this.Width / 2) - (TextSize.Width / 2);
TextPos.Y = (this.Height / 2) - (TextSize.Height / 2); …Run Code Online (Sandbox Code Playgroud) 我有一个线程,可以通过调用Canvas控件的redraw方法来对gif图像进行动画处理。但是会观察到图像闪烁。我尝试使用SWT.NO_REDRAW_RESIZE样式位,但没有帮助。
下面是线程的运行代码
while (!UIManager.stop){
long currentTime = System.currentTimeMillis();
int delayTime = UIManager.loader.data[UIManager.imageNumber].delayTime;
while(currentTime + delayTime * 10 > System.currentTimeMillis()){
// Wait till the delay time has passed
}
UIManager.imageNumber = UIManager.imageNumber == UIManager.loader.data.length-1 ? 0 : UIManager.imageNumber+1;
display.asyncExec(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
if(!UIManager.stop){
UIManager.image = new Image(display, UIManager.loader.data[UIManager.imageNumber] );
if(!UIManager.gifCanvas.isDisposed())
UIManager.gifCanvas.redraw();
}
}
});
Run Code Online (Sandbox Code Playgroud)
画布绘制侦听器如下
gifCanvas = new Canvas(gifComposite,SWT.NO_REDRAW_RESIZE);
gifCanvas.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gifCanvas.setLayoutData(introGifData);
gifCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(image,0,0);
}
}); …Run Code Online (Sandbox Code Playgroud) 所以我想制作一个廉价的Gyazo副本(截图工具)
问题是光标坐标是闪烁的,我该如何防止?我已经尝试过,WM_ERASEBKGND但它没有任何帮助.
我的代码还有什么问题吗?任何不良做法/技巧?
#include <Windows.h>
#include <string>
#include <gdiplus.h>
#pragma comment (lib, "Gdiplus.lib")
// Store the "screenshot" when first launching the program
HBITMAP hbm;
// This draws the cursor coordinates close to the cursor
void DrawCursorCoords(Gdiplus::Graphics &graphics, Gdiplus::Bitmap &bitmap, Gdiplus::Color c)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
std::wstring x = std::to_wstring(cursorPos.x);
std::wstring y = std::to_wstring(cursorPos.y);
graphics.DrawString(x.c_str(), x.length(), &Gdiplus::Font(L"Consolas", 16), Gdiplus::PointF(cursorPos.x, cursorPos.y), &Gdiplus::SolidBrush(c));
graphics.DrawString(y.c_str(), y.length(), &Gdiplus::Font(L"Consolas", 16), Gdiplus::PointF(cursorPos.x, cursorPos.y + 16), &Gdiplus::SolidBrush(c));
}
// Paint our stuff
void Paint(HDC &hdc)
{ …Run Code Online (Sandbox Code Playgroud) 我已经在这个程序上工作了大约一个月了,尝试了一切。无论我做什么,我的程序都会闪烁,即使在其他机器上也是如此。它只是一个背景、一个图像和一个矩形。没有什么大的或昂贵的。然而它仍然闪烁。我试过将 DoubleBuffered 设置为 true,我试过覆盖 CreateParams(它使我的窗口变黑),我试过使用反射的方法,我试过 SetStyle 来设置 DoubleBuffer、OptimizedDoubleBuffer、UserPaint、AllPaintingInWmPain 和 Opaque当设置为 true 时,他们都没有做任何事情。我已经在 google 和 stackoverflow 上搜索了答案,但没有一个起作用。我无法理解我做错了什么。我添加了代码、exe、编译脚本和图像的 zip。我和其他人的计算机上发生的事情就是 gif 上的内容。该程序每秒更新 4 次,足以绘制背景、图像和正方形的时间,但它仍然闪烁。请我需要帮助。
主文件:
using System;
using System.Threading;
using System.Windows.Forms;
public class main{
public static void Main(string[] args){
Console.WriteLine("START");
Engine.Init();
while(true){
Engine.MainDraw();
Application.DoEvents();
Thread.Sleep(250);
}
Console.WriteLine("END");
}
}
Run Code Online (Sandbox Code Playgroud)
引擎.cs:
using System;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Drawing;
public class Engine : Form{
public static Engine EngineForm = new Engine();
public static Graphics g;
/*
protected override CreateParams CreateParams{
get{
CreateParams …Run Code Online (Sandbox Code Playgroud) 有谁知道什么可能导致Firefox闪屏?它会在短时间内变黑.我认为这是"回流",但我无法弄清楚是什么导致了它.
我尝试过禁用转换,自定义字体,渐变,但它仍然会发生.
它可以是柔性盒吗?因为我到处都在使用它们,并且在我切换到柔性盒后我发现FF有些滞后.