gdi

Problem with WPF graph control

hi guys, I've developed a graph control in GDI+ and used a timer in it.. now i'm converting it to WPF. but when i went on and search for a timer there is no timers in WPF... how can i resolve this problem?any alternative to use? regards, rangana. ...

Convert from 32-BPP to 8-BPP Indexed (C#)

I need to take a full color JPG Image and remap it's colors to a Indexed palette. The palette will consist of specific colors populated from a database. I need to map each color of the image to it's "closest" value in the index. I am sure there are different algorithms for comparing and calculating the "closest" value. Looking for C#, .N...

GDI+ performance tricks

Does anyone know of any reliable (and, hopefully, extensive) books/websites that discuss GDI+ performance (beyond the obvious)? For example, I recently came across this excellent experiment. I also recently noticed that Graphics.FillPath() is way, way faster than Graphics.DrawPath(). I'd love to know what other vital bits of information...

How do I use GDI+ to change the color of a line when it overlaps a region?

I'm using .NET GDI+ to draw a wavy line on a chart. (think sharetrading) I want it to change color if the line goes above 90% or below 10%. Any tips on how to get the color to change? My two ideas are:- 1. Create rectangles from 0%-10% & 90%-100% & somehow use them are a color clipping/transform region. is that possible if so how. 2. ...

WPF Image won't display BitmapSource

I'm new to using WPF and GDI, and I'm having trouble displaying an image. My eventual goal is to build something expose-like. So far, I gray-out the screens, gather all the active HWNDs, and capture the screens of all the windows. For now, I have a single Image element that I try to set the source for, but nothing ever shows up. foreach...

Remove alpha from a BitmapSource

Hello, I use BitBlt() and CreateBitmapSourceFromHBitmap() to capture a window as a BitmapSource that I can display on an Image element in a WPF application. But for some reason, most of the application that it captures is transparent. Here is a source vs. capture image of what's happening: It's gray because the background of the wind...

wxGraphicsContext dreadfully slow on Windows

I've implemented a plotter using wxGraphicsContext. The development was done using wxGTK, and the graphics was very fast. Then I switched to Windows (XP) using wxWidgets 2.9.0. And the same code is extremely slow. It takes about 350 ms to render a frame. Since the user is able to drag the plotter with the mouse to navigate it feels very...

Win32 DrawText line height

I'm calling the Win32 DrawText function to output some text into a device context. The text is long and wraps nicely onto a second line. The problem is I need to decrease the space between lines a bit (I guess decrease the line height?). Any ideas on how to do this? I would just call DrawText twice (one for each line) but then I ha...

WMF / EMF File Format conversion C#

In my program, I have a requirement to "playback" or "parse" windows metafiles (WMF and EMF). I have dug through MSDN and Google, and the closest I have come is the Graphics. EnumerateMetafile method. I can get it to work, in that my EnumerateMetafileProc callback is called, and I can then call PlayRecord. What is missing, is how to get ...

C# GDI Draw Points onto canvas using an offset?

I have an array of Point variables. When drawn using Graphics.Drawline, they create the expected image. My problem is that 0,0 is actually the center of the image (not the top left of my canvas as expected. My X and Y coordinates in the Points can contain negative numbers. When I try to draw this to my Image, of course I get 1/4 of the...

C# GDI Invert Graphics flipped on the X axis

I am drawing a series of Points using the Graphics class. I am reading from a Point array. For whatever reason the rendered image is upside down (flipped on the X axis). Is there a simple way to tell the Graphics class to draw "upside down" ? Many thanks. ...

Gdi Guidance required

I am currently working in C# with wpf, I don't know about graphics, I want to learn about GDI and graphics from scratch, Can anyone help me by providing some basic knowledge or material? Can anyone tell me to write very first program using Gdi? ...

GDI+: Limitations of Paths and Regions

Are there limits/differences when performing GDI operations on off-screen objects like paths/regions as compared to performing the same operations on the display? What limits can I expect when performing graphics operations on a region/path as opposed to performing them directly on the display? When performing GDI operations on GDI reg...

How to measure the pixel width of a digit in a given font / size (C#)

I am trying to calculate the pixel width of Excel columns, as described in this post, using the official formula from the OpenXML specification. However, in order to apply this formula, I need to know the Maximum Digit Width of the Normal font, which is the pixel width of the widest numeric digit. The OpenXML specification gives this exa...

Using AlphaBlend() and FillRect()

So, I'm using AlphaBlend() to copy a rectangle from one HBITMAP to another. It works, but there is a problem. Whenever I use the FillRect() function, the alpha values in the HBITMAP get slammed out to 0. Everytime. So I have to GetDIBits(), reset the alpha back to 255, and then SetDIBits(), after every call to the Win32 api functions...

How to use Win32's BitBlt using Ruby?

Does anyone know how to use Win32's BitBlt() using Ruby? It seems like you need to use a destination DC (device context) and how can Ruby handle that? I use GetPixel() and it is really slow even to get 100 pixels (takes about 10 seconds). thanks. ...

How do I implement layer with GDI?

I want to implement a rubber function just like photoshop, but I hope the rubber just to erase the shapes that drawed on background without modifying the background. Now the background is a image so I can't use the brush with the single color. ...

Deserialize Bitmap from Archive

Hello, everyone! I've got a problem with my MFC app. When I'm trying to deserialize CBitmap from the archive and create new CBitmap, it doesn't properly load CBitmap's bits. Here's the code: BITMAP bm; ar >> bm.bmType; ar >> bm.bmWidth; ar >> bm.bmHeight; ar >> bm.bmWidthBytes; ar >> bm.bmPlanes; ar >> bm.bmBitsPixel; int nSize = bm.b...

Drawing controls with GDI on Compact Framework

I need to draw a textbox in a Compact Framework app, but using directly a Graphics object. I've found the Control.DrawToBitmap method, which I could use for drawing with GDI, but it's not available on Compact Framework. Any hints? ...

Flip-3D on WinXP and taking layered screenshot

Hello guys, I have two questions but somehow related: How to implement flip 3d without Aero APIs on Windows XP? Have you guys seen this awesome app on Mac? http://layersapp.com Is there any possibility to have something similar on Windows? If the #1 question is solved I think we can make something like that I know how to take a scree...