Click here to Skip to main content
15,923,087 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProgram start (problem) Pin
david bagaturia15-Apr-07 22:53
david bagaturia15-Apr-07 22:53 
AnswerRe: Program start (problem) Pin
CPallini15-Apr-07 23:10
mveCPallini15-Apr-07 23:10 
GeneralRe: Program start (problem) Pin
david bagaturia16-Apr-07 1:09
david bagaturia16-Apr-07 1:09 
QuestionResolution problem with Gdiplus.. Pin
HuddartG15-Apr-07 22:12
HuddartG15-Apr-07 22:12 
AnswerRe: Resolution problem with Gdiplus.. Pin
Mark Salsbery16-Apr-07 6:51
Mark Salsbery16-Apr-07 6:51 
GeneralRe: Resolution problem with Gdiplus.. Pin
HuddartG16-Apr-07 21:23
HuddartG16-Apr-07 21:23 
GeneralRe: Resolution problem with Gdiplus.. Pin
Mark Salsbery17-Apr-07 6:22
Mark Salsbery17-Apr-07 6:22 
GeneralRe: Resolution problem with Gdiplus.. Pin
HuddartG18-Apr-07 0:52
HuddartG18-Apr-07 0:52 
Hi Mark,

Thanks for your reply. I tried my application on a different machine/monitor and I had exactly the same problem.

I then asked myself what GDI+ could be doing when rotating as opposed to not rotating. After hitting on several websites (including "http://www.leunen.com/cbuilder/rotbmp.html") I concluded that there must be some copying taking place. I then experimented by taking a clone of my original bitmap and my findings were interesting to say the least. Let me first show you my latest modified code..

// Create a GDI Plus graphics object
Graphics graphics(pDC->GetSafeHdc( ) );

etc, etc..

// Get size and offset depending on orientation and aspect of image (my function)
GetSizeAndOffset(RectImage, Orientation, orig_width, orig_height, new_width, new_height, top_left_x, top_left_y);

// Translate the origin
graphics.TranslateTransform(top_left_x, top_left_y);

// Check for rotation request
if (bRotate)
{
// Apply rotation
graphics.RotateTransform(Orientation); // No problem if do this
}
else
{
UINT u_width = pGdiBitmap->GetWidth( ); // Typically 2303
UINT u_height = pGdiBitmap->GetHeight( ); // Typically 1727

// If I decrement by 1 (or more) then the image quality is superb. With zero decrement
// I get the same poor resolution as before. If I increment then I get no image at all.
u_width -= 1;
u_height -= 1;

// Store pointer to original bitmap
Bitmap *pOriginalBitmap = pGdiBitmap;

// Get a slightly reduced clone of the original
pGdiBitmap = pOriginalBitmap->Clone(0, 0, u_width, u_height, PixelFormatDontCare);

// Calling this will actually degrade image quality
// graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);

// Release the original bitmap
delete pOriginalBitmap;
}

// Draw the image
draw_status = graphics.DrawImage(pGdiBitmap, 0.0f , 0.0f, new_width, new_height);

etc, etc..

If I clone only a portion of my original bitmap then I get sharp images (even without promoting the interpolation mode). If I maintain the size of the bitmap then poor image quality returns. Interestingly, I get degradation of image quality if I promote the interpolation mode.

The upshot of all this is that I have partially solved my problem. However, I do suffer a slight loss data (though not a big issue) and I also take a hit on performance due to cloning.

I am puzzled, however, as to why I am experiencing this phenomenon. I do not see how simply reorganising the bits in the bitmap can be enhancing image quality. Looking once again at "www.leunen.com/cbuilder/rotbmp.html" my suspicions now centre on the DIB section. Could it be that GDI+ is, under certain conditions, modifying DIB section attributes when rotating/cloning? If so then I can modify these attributes for myself without the need to clone. I would appreciate your comments on this.

Cheers, Graham

Graham
Question.msi file Pin
prathuraj15-Apr-07 21:53
prathuraj15-Apr-07 21:53 
QuestionRe: .msi file Pin
sthotakura16-Apr-07 7:22
sthotakura16-Apr-07 7:22 
Questionhow to access string table of .lib file from an EXE Pin
GANsJob15-Apr-07 21:33
GANsJob15-Apr-07 21:33 
Questionhow can i debug my dll in officexp Pin
ytfrdfiw15-Apr-07 21:31
ytfrdfiw15-Apr-07 21:31 
AnswerRe: how can i debug my dll in officexp Pin
Gospodin Baron15-Apr-07 22:13
Gospodin Baron15-Apr-07 22:13 
GeneralRe: how can i debug my dll in officexp Pin
ytfrdfiw15-Apr-07 22:26
ytfrdfiw15-Apr-07 22:26 
GeneralRe: how can i debug my dll in officexp Pin
toxcct15-Apr-07 22:29
toxcct15-Apr-07 22:29 
GeneralRe: how can i debug my dll in officexp Pin
ytfrdfiw15-Apr-07 23:26
ytfrdfiw15-Apr-07 23:26 
GeneralRe: how can i debug my dll in officexp Pin
Gospodin Baron15-Apr-07 23:47
Gospodin Baron15-Apr-07 23:47 
GeneralRe: how can i debug my dll in officexp Pin
ytfrdfiw26-Mar-10 3:16
ytfrdfiw26-Mar-10 3:16 
Questionscope in functions Pin
minkowski15-Apr-07 21:21
minkowski15-Apr-07 21:21 
AnswerRe: scope in functions Pin
Programm3r15-Apr-07 21:26
Programm3r15-Apr-07 21:26 
AnswerRe: scope in functions Pin
CPallini15-Apr-07 21:34
mveCPallini15-Apr-07 21:34 
GeneralRe: scope in functions Pin
minkowski15-Apr-07 21:39
minkowski15-Apr-07 21:39 
GeneralRe: scope in functions Pin
cp987615-Apr-07 21:50
cp987615-Apr-07 21:50 
GeneralRe: scope in functions Pin
minkowski15-Apr-07 21:54
minkowski15-Apr-07 21:54 
GeneralRe: scope in functions Pin
toxcct15-Apr-07 22:12
toxcct15-Apr-07 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.