gdi

Limiting File Size when Resizing with GDI+

I am resizing uploaded images as follows: var bmPhoto = new Bitmap(width, height, PixelFormat.Format16bppRgb555); using (var grPhoto = Graphics.FromImage(bmPhoto)) { grPhoto.SmoothingMode = SmoothingMode.HighSpeed; grPhoto.CompositingQuality = CompositingQuality.HighSpeed; grPhoto.InterpolationMode = InterpolationMode.Low; grPh...

DWM Composition toggle causes client area to lose alpha

I have a simple Windows application here: http://www.bengoodger.com/software/chrome/dwm/app.cc My app provides a customized glass frame for when DWM compositing is active, and a fully custom frame when it is inactive or not available. The "customized glass frame" consists of a enlarged title bar area, which is reported by my implement...

GetPixel always returns CLR_INVALID

I'm trying to read the pixel color of a given window. The window is not mine. The window may not have focus or be at foreground. I don't know if it matters, does it? I have the window handle, so I do: HDC hdc = GetDC(m_window); if (hdc) { COLORREF color = GetPixel(hdc,x,y); if(color == CLR_INVALID) { wxLogDebug...

Image with rounded corner and shadow

Hi all, How to make an rounded corner image with shadow effect for an image uploaded by user in C#? ...

obtain x,y coords of individual Chars in a SWT text widget

If i write a text on SWT say "this text" in a particular font/style , i want the individual coords of 't' 'h' 'i' 's' and so on. Is there any way to obtain the same. ...

obtain x,y coords of individual Chars in a gdi widget

if i use textout("this text") with a particular font/style, i want to find out the (x,y) coords of 't' 'h' 'i' 's' chars. i cant use the printer route. how else can i obtain the individual x,y coords. ...

Erasing the background of the drop-down list of a subclassed combo

Hello, I have an issue with the drop-down list of a subclassed combo box, with its background actually. The situation is the following: there is a big holder window which contains a combo box, subclassed. The window class of the main window specifies a gray brush (COLOR_3DFACE), used by Windows to erase its background. The combo box i...

Specifying DPI of a GDI Device Context

I have an application that generates metafiles (EMFs). It uses the reference device (aka the screen) to render these metafiles, so the DPI of the metafile changes depending on what machine the code is running on. Let's say my code is intending to create a metafile that is 8.5 in x 11 in. Using my development workstation as a reference, ...

Why won't GDI let me delete large images?

My ASP.NET application has an image cropping and resizing features. This requires that the uploaded temporary image be deleted. Everything works fine, but when I try to delete an image larger than 80px by 80px I get a "File is locked by other process..." error, even though I've released all resources. Can anyone help? I'm tired of Googl...

How do I set a pixel color in a texture using ManagedDX?

Hey guys, I need to set a specific pixel in a texture to a custom color, for doing that I made a Bitmap and I always set the pixel in the bitmap, then I recreate the texture from the bitmap. Doing that is very time consuming, is there any way to modify the pixel directly in the texture? ...

C# OnPaint mousemove high cpu usage

I have written a custom control that renders some graphics. The graphics itself is fairly expensive to render but once rendered it rarely changes. The problem I have is that if you move the mouse really fast over the graphics surface it keeps calling the control's overridden Paint method which then incurs a high CPU penalty: private voi...

Redirect hwnd GDI calls to system memory bitmap?

I have a 3rd party ActiveX control I want to render within other presentation technologies (Direct3D and WPF). To do this, I need the ActiveX to render to a system memory bitmap instead of the screen. I know there is a way to do this, but not sure where to start. I'm not afraid of doing any native method hooking, but I'm not sure wher...

Custom-drawn control won't render controls behind it even though it's transparent

I'm currently writing a custom-designed tab control. I created my own control instead of owner-drawing the TabControl because I figured it'd be faster and more flexible. My tab control styles itself after the VS2008 tab control; that is, when a tab is selected, part of that tab is in front of other, unselected tabs. My tab control consi...

How to not discard a CDC path?

I draw some symbols, that belong to certain objects, into a device context and now want to be able to later test if the mouse cursor is above such a symbol. To do this, my plan was to first create a CDC path and use that to create a CRgn region object. pDC->BeginPath(); pDC->Ellipse(ellipse[0], ellipse[1], ellipse[2], ellipse[3]); // C...

Move a bitmap around a window quickly in C++

I'm looking for some C++ code to let me quickly move a bitmap around a window, restoring the background as it moves. At present I capture the Window contents to a bitmap during the app initialization and in the OnPaint() I draw the this bitmap and then I draw my overlayed bitmap. I am double buffering the paint. The overlayed bitmap posi...

Zoom to the center of view port

I'm currently trying to write a zoomable UserControl and I've currently followed Bob Powell's example at http://www.bobpowell.net/zoompicbox.htm, however, what I'm trying to achieve is zooming to the center point of the control not the top left corner. Is anybody having experience/idea on this? thanks. ...

With PHP/GD, how do I trim an image?

I want to mimic the trim behavior of Photoshop (crop the area that is covered by the same color on all sides) with GD and PHP but I'm lacking ideas on how to accomplish this. If someone has any idea on how to do this I would very much like to hear it. Thanks in advance. ...

Correlating Windows forms textbox text width to GDI width

I'm drawing the text from a textbox using GDI; however, I'm trying to create my textbox such that it reflects the same amount of space that I am drawing to in GDI. So, for some X amount of width in GDI, I would like for the length of the string in the textbox to not be able to exceed this width. To draw the string in GDI, I'm using the...

Double buffering in WPF?

hi guys, I'm developing a graph control in WPF. I have previously developed it using GDI and C#. i've used double buffering in previous control to avoid some issues related to redrawing of the graph control. Now when i've developed the Graph Control in WPF i have a problem, when i use my Graph Control as a user control in a windows form...

Generating large amounts of PDF Docs from templetes

Where I work we get PDF templetes from our clients and we convert them into html templates that we can change out tokens in the page with other info and mail them out to their clients. The reason we convert them into html is because the text can wrap if any of the info is too long. The process can be slow since we can only do 1 at a ti...