mfc >> Copying images

by Q2hhcmxlcw » Tue, 25 Jan 2005 06:53:03 GMT

Hi, I am using a bitmap as an off screen DC to stop flickering in a graph
control inherited from a static control.
However, I would also like to be able to export an image version of this
graph.
Currently I am trying to use the following code:
"
void CMemDC::FillImage(CImage* pImage)
{
CImage localImage;
localImage.Attach(m_bitmap);

pImage->Create(m_rect.Width(), m_rect.Height(), 24);
localImage.BitBlt(pImage->GetDC(),0,0);
}
"
However, this causes BitBlt to assert I was wondering if anyone would be
able to tell me how to copy the contents of m_bitmap into pImage.

Thanks in advance,
Charles


Similar Threads

1. Copying images from toolbar image list to system menu

I have a program where I used Win32 calls to add items to my form's system
menu.  Now I am attempting to have those items use the same icon that the
corresponding toolbar button uses.  I thought that I could just access the
image on the fly and send it to Windows.  Trouble is that results in an
image with dark blue where the image is transparent.  (The menu's background
is the standard BTNFACE color.)  My code is below.  All need is a HBITMAP.
Windows is definitely insisting on a bitmap rather than an icon.  Could
someone tell me what is wrong?  Do I need to paint the image somewhere?  I
would rather just copy it.

((System.Drawing.Bitmap)ilToolbarSmall.Images[iUncheckedIconIndex]).GetHbitm
ap()
----------
Will Pittenger
E-Mail: mailto: XXXX@XXXXX.COM 
All mail filtered by Qurb (www.qurb.com)


2. Clipboard reduces the resolution of the copied image

3. Copying Images.

Use CopyRect() VCL function, something like this

i1->Canvas->CopyRect(Dest, i2->Canvas, Source);

or

i2->Canvas->CopyRect(Dest, i1->Canvas,  Source);

Rodolfo

"Scott Kent-Collins" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> I have a TImage control, say Image1, that contains a picture (Bitmap
file).
> The Stretch property on this TImage control is set to TRUE so that the
> complete image is displayed.



4. Copying image to clipboard

5. Screen Capture (Screen Copying) example / the perils of Image/ Bitmap copying to file

6. Copy tables and images from one richtextbox to another - CSharp/C#

7. ImageList indexer returns Copy of Image instead of Reference

We're using a System.Windows.Forms.ImageList to store a bunch of Images that 
I've loaded, and rendering each image in the ImageList during a draw loop.  
The process was running unusually slow and was causing memory spikes.  After 
several hours we discovered that the ImageList.Images indexer is actually 
returning a copy of the added Images instead of simply returning a reference. 
 Needless to say, we were a bit surprised and disturbed to discover this.

1) Can anyone answer why the ImageList collection returns a copy instead of 
a reference?

2) Is there a way to get the reference instead of a copy?

If you run the example code below, the output to the console window will be 
"Different Image".

// Example Code

System.Windows.Forms.ImageList imageList = 
   new System.Windows.Forms.ImageList();

System.Drawing.Image image = 
   System.Drawing.Image.FromFile(@"C:\image.png");

imageList.Images.Add(image);

// Get the same Image twice!
System.Drawing.Image imageFromList1 = imageList.Images[0];
System.Drawing.Image imageFromList2 = imageList.Images[0];

if (object.ReferenceEquals(imageFromList1, imageFromList2))
{
   Console.WriteLine("Same Image");
}
else
{
   Console.WriteLine("Different Image");
}

Console.ReadLine();

8. try to create copies of an image object created using resource - CSharp/C#