HighTechTalks DotNet Forums  

Re: Bob Powell Pls Help me

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Re: Bob Powell Pls Help me in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Hariharan
 
Posts: n/a

Default Re: Bob Powell Pls Help me - 07-04-2003 , 08:14 AM






Thanks for your reply.

I just missed to furnish one more information. int 24 bit
True color display setting both looking fine. but in 256
color mode and 16 bit color mode it is giving problems.

first i thought that it was due to palette. but
even after using the palette for the Dc of the graphics it
is the same.

Then only i tried what i 've asked for you.

I want to display a magnifier glass over the bitmap in the
picture box.

I am using the picture box only as a container.

Say my 8bpp indexed grayscale bitmap (with palette entries
0,0,0 ....255,255,255) entries(Totally 256 entries).

In 256 color mode if i draw it is coming differently.

Onpaint() will have a code

e.Graphics.DrawImage
(imageToBeRendered,targetRect,rectInImage.Left,rec tInImage.
Top,rectInImage.Width,rectInImage.Height,GraphicsU nit.Pixel
);


On clicking the image i'll store the screen dc into one
offscreen bmp

offScreenBmp =
new Bitmap(((PictureBox)nder).ClientRectangle.Size.Wid th,
((PictureBox)sender).ClientRectangle.Size.Height,
((PictureBox)sender).CreateGraphics());
offScreenGraphics = Graphics.FromImage(offScreenBmp);

Graphics G = ((PictureBox)sender).CreateGraphics();
IntPtr offHDC = offScreenGraphics.GetHdc();
SetPalette(offHDC);//This is my function

IntPtr onLineHDC =
G.GetHdc();
BitBlt(offHDC,0,0,
((PictureBox)sender).Width,((PictureBox)
sender).Height,onLineHDC,0,0,SRCCOPY);
BitBlt
(onLineHDC,0,0,((PictureBox)sender).Width,((Pictur eBox)
sender).Height,offHDC,0,0,SRCCOPY);

offScreenGraphics.ReleaseHdc(offHDC);
G.ReleaseHdc
(onLineHDC);



The SetPalette function is



public void SetPalette(IntPtr hdc)
{
PALETTEENTRY [] palEntry = new
PALETTEENTRY[256];
LOGPALETTE [] logpal1 = new
LOGPALETTE[1];
fixed(PALETTEENTRY *palentry1 =
palEntry)
{

fixed(LOGPALETTE* logpal
= logpal1)
{
logpal-
Quote:
palPalEntry = palentry1;
for(int
i=0;i<232;i++)
{
logpal-
Quote:
palPalEntry[i].peBlue = PaletteEntries[i];
logpal-
palPalEntry[i].peGreen = PaletteEntries[i];
logpal-
palPalEntry[i].peRed = PaletteEntries[i];
logpal-
palPalEntry[i].peFlags = 0;
}
logpal-
Quote:
palNumEntries = 232;
logpal->palVersion
= 768;
IntPtr hPal =
CreatePalette(logpal);

if(hPal ==
IntPtr.Zero)
{

MessageBox.Show("PALette creation Failed");
return;
}
if(SelectPalette
(hdc, hPal, true)!= IntPtr.Zero)
{
int t =
RealizePalette(hdc);
}

}

}
}
I've defined the structures in C# equivalent to that of
WINAPI structures.


if the mouse is moved to the new location i 'll calculate
the rectangle portion that needs to be repainted and i'll
draw the image from offscreen bmp to the
picturebox.CreateGraphics()

if i draw in this graphics on moving the mouse the image
is begiinning to look ugly.

Thanks
Hari





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.