Click here to Skip to main content
15,892,059 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
Questionis setting an object reference atomic? Pin
Member 168528-Feb-05 21:51
Member 168528-Feb-05 21:51 
AnswerRe: is setting an object reference atomic? Pin
S. Senthil Kumar1-Mar-05 9:13
S. Senthil Kumar1-Mar-05 9:13 
GeneralRe: is setting an object reference atomic? Pin
Member 16851-Mar-05 9:49
Member 16851-Mar-05 9:49 
GeneralRe: is setting an object reference atomic? Pin
S. Senthil Kumar1-Mar-05 16:01
S. Senthil Kumar1-Mar-05 16:01 
GeneralWindows Forms ListBox "GetItemValue" method Pin
dxlee28-Feb-05 8:48
dxlee28-Feb-05 8:48 
GeneralMDI Window Pin
Small Rat28-Feb-05 4:46
Small Rat28-Feb-05 4:46 
GeneralInstaller don`t remove assemblies Pin
Adnan Siddiqi28-Feb-05 0:22
Adnan Siddiqi28-Feb-05 0:22 
GeneralProblem rendering bitmaps with .NET CF Pin
Georg Fuchs27-Feb-05 23:07
Georg Fuchs27-Feb-05 23:07 
Hello,

this might be a stupid question, but i haven't found an answer on either this forum or the MS knowledge base, so here is my problem:

On a PocketPC 2003 and using the Compact Framework, I want to create a copy from an image (an embedded resource 24bpp png), modify that copy and use it in subsequent redraws of a control (a class deriving from Forms.Control and overriding OnPaint).

For this I use the copy-contructor of the Bitmap class (dstImage is a member of the control):
dstImg = new Bitmap(srcImage);

This seems to be a valid copy of the source image, dstImage.GetPixel returns color values identical to srcImage.GetPixel throughout, and the Width and Height properties show the expected image size. However, when I render that image to the control with
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    e.Graphics.DrawImage(dstImg, 0, 0);
    // An alternative that doesn't work any better
    //Rectangle r = new Rectangle(0, 0, srcImage.Width, srcImage.Height);
    //e.Graphics.DrawImage(dstImg, r, r, GraphicsUnit.Pixel);
    // Junxtapose original to the right of dstImg, it will have the correct size:
    e.Graphics.DrawImage(srcImage, dstImage.Width + 1, 0);
}

then the image is only about a quarter in size of what it should be. It is not truncated (and small enough to fit in the control entirely), but scaled down. Using srcImage in the above code does not exhibit this unwanted scaling. Please note that there is code ensuring that dstImage is only attempted to be drawn when its production is finished (omitted for brevity).

I've also tried to use different means of contructing dstImg, like
dstImg = new Bitmap(srcImage.Width, srcImage.Height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(dstImg);
Rectangle r = new Rectangle(0, 0, srcImage.Width, srcImage.Height);
g.DrawImage(srcImage, r, r, GraphicsUnit.Pixel);
g.Dispose();

A final note: this problem is specific to the compact framework. If I paste the above snippets in a 'full' framework app and run it, both original and copy show correctly. I suspect this behaviour might result from some mismatch of the DPI settings, however you can't seem to access these members (HorizontalResolution and VerticalResolution) in the CF? What am I missing/doing wrong? Confused | :confused:

Any help and subtle pointers to possible stupidity on my part would be appreciated,

Georg
QuestionRun .Net on Win95? Pin
P-TAE27-Feb-05 19:02
P-TAE27-Feb-05 19:02 
AnswerRe: Run .Net on Win95? Pin
Colin Angus Mackay27-Feb-05 19:40
Colin Angus Mackay27-Feb-05 19:40 
GeneralWindows Hooks Pin
Member 176527127-Feb-05 13:39
Member 176527127-Feb-05 13:39 
GeneralRe: Windows Hooks Pin
ursus zeta28-Feb-05 15:07
ursus zeta28-Feb-05 15:07 
Questionwhy .net...? Pin
Hamed Musavi26-Feb-05 16:09
Hamed Musavi26-Feb-05 16:09 
AnswerRe: why .net...? Pin
Colin Angus Mackay26-Feb-05 16:43
Colin Angus Mackay26-Feb-05 16:43 
GeneralRe: why .net...? Pin
S. Senthil Kumar26-Feb-05 19:49
S. Senthil Kumar26-Feb-05 19:49 
GeneralRe: why .net...? Pin
Hamed Musavi27-Feb-05 16:54
Hamed Musavi27-Feb-05 16:54 
GeneralRe: why .net...? Pin
Colin Angus Mackay27-Feb-05 19:40
Colin Angus Mackay27-Feb-05 19:40 
GeneralRe: why .net...? Pin
Hamed Musavi28-Feb-05 16:00
Hamed Musavi28-Feb-05 16:00 
GeneralRe: why .net...? Pin
Colin Angus Mackay28-Feb-05 20:25
Colin Angus Mackay28-Feb-05 20:25 
GeneralRe: why .net...? Pin
Hamed Musavi28-Feb-05 21:58
Hamed Musavi28-Feb-05 21:58 
GeneralEXTRA new news EXTRA, Read this Please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Pin
Hamed Musavi1-Mar-05 15:35
Hamed Musavi1-Mar-05 15:35 
GeneralRe: EXTRA new news EXTRA, Read this Please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Pin
DavidNohejl2-Mar-05 9:34
DavidNohejl2-Mar-05 9:34 
GeneralRe: why .net...? Pin
zuschauer19801-Mar-05 0:12
zuschauer19801-Mar-05 0:12 
GeneralRe: why .net...? Pin
Hamed Musavi1-Mar-05 15:26
Hamed Musavi1-Mar-05 15:26 
QuestionWebRequest Problem??? Pin
Small Rat26-Feb-05 7:00
Small Rat26-Feb-05 7:00 

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.