DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 6 Aug 2007 12:45:24 -0400,    posted on: microsoft.public.dotnet.framework.drawing        back       

Thread Index
  1    active
          2    Michael Phillips, Jr. 0.c0m
          3    active
          4    Michael Phillips, Jr. 0.c0m
          5    active
                 6    Michael Phillips, Jr. 0.c0m
          7    active


clipboard converts 8bpp to 32bpp   
I place a Bitmap on the clipboard with:

Clipboard.SetData(DataFormats.Bitmap, BackgroundImage)



Then retrive it with:

d = CType(DataO.GetData(DataFormats.Bitmap, False), Bitmap)



I place an 8ppbIndexed bitmap on the clipboard a get a 32bpprgb bitmap back.

Am I stuck with that or i there some way I can get what I put?

Does the conversion happen whem I'm putting it on the clipboard or when I'm 
retrieving it?

If anyone knows what's happening I'd appreciate the info!



thanks
Date:Mon, 6 Aug 2007 12:45:24 -0400   Author:  

Re: clipboard converts 8bpp to 32bpp   
If you want to place an indexed bitmap on the clipboard then you have three 
choices:
1) Use CF_BITMAP and CF_PALETTE with SetClipboardData to place the handles 
to the DIB bitmap and palette on the clipboard.
2) Use CF_DIB with SetClipboardData to place an indexed DIB on the 
clipboard.
Of course this means your bitmaps in 1) or 2) must be created with 
CreateDIBSection.
3) The Bitmap's native format is 32bpp, so your bitmap is converted when 
placed and retrieved from the clipboard.
    If you do not want to use CreateDIBSection, then construct a 
MemoryStream for the indexed DIB
    by using LockBits and use DataFormats.DeviceIndependentBitmap with 
SetData with the MemoryStream object
    make sure you rewind it before placing it on the clipboard.
    Constructed MemoryStream for DIB:
    1) BITMAPFILEHEADER
    2) BITMAPINFOHEADER
    3) Color Table
    4) Bits <----Use LockBits to copy the indexed bitmap's bits to the 
MemoryStream object


" active"  wrote in message 
news:uRpMSlE2HHA.5360@TK2MSFTNGP03.phx.gbl...

>I place a Bitmap on the clipboard with:
>
> Clipboard.SetData(DataFormats.Bitmap, BackgroundImage)
>
>
>
> Then retrive it with:
>
> d = CType(DataO.GetData(DataFormats.Bitmap, False), Bitmap)
>
>
>
> I place an 8ppbIndexed bitmap on the clipboard a get a 32bpprgb bitmap 
> back.
>
> Am I stuck with that or i there some way I can get what I put?
>
> Does the conversion happen whem I'm putting it on the clipboard or when 
> I'm retrieving it?
>
> If anyone knows what's happening I'd appreciate the info!
>
>
>
> thanks
>
>
>
> 
Date:Mon, 6 Aug 2007 17:04:22 -0400   Author:  

Re: clipboard converts 8bpp to 32bpp   
"Michael Phillips, Jr." <mphillips53@nospam.jun0.c0m> wrote in message 
news:%23Klxt1G2HHA.1336@TK2MSFTNGP04.phx.gbl...

> 3) The Bitmap's native format is 32bpp, so your bitmap is converted when 
> placed and retrieved from the clipboard.


I just want to confirm that this means a Bitmap is always  32bpp when placed 
and retrieved on/from a clipboard, no matter how that is effected.

Right?

I know that's what you said but that's exactly what I've been trying to get 
around - and I believe you said I can't (using CF_BITMAP)

Thanks
Date:Mon, 6 Aug 2007 19:12:52 -0400   Author:  

Re: clipboard converts 8bpp to 32bpp   

> I just want to confirm that this means a Bitmap is always  32bpp when 
> placed and retrieved on/from a clipboard, no matter how that is effected.
>
> Right?


If it passed as a System.Drawing.Bitmap, yes


> I know that's what you said but that's exactly what I've been trying to 
> get around - and I believe you said I can't (using CF_BITMAP)


You can if you pass a handle created by CreateDIBSection

" active"  wrote in message 
news:u3w$Q9H2HHA.5884@TK2MSFTNGP02.phx.gbl...

>
> "Michael Phillips, Jr." <mphillips53@nospam.jun0.c0m> wrote in message 
> news:%23Klxt1G2HHA.1336@TK2MSFTNGP04.phx.gbl...
>> 3) The Bitmap's native format is 32bpp, so your bitmap is converted when 
>> placed and retrieved from the clipboard.
>
> I just want to confirm that this means a Bitmap is always  32bpp when 
> placed and retrieved on/from a clipboard, no matter how that is effected.
>
> Right?
>
> I know that's what you said but that's exactly what I've been trying to 
> get around - and I believe you said I can't (using CF_BITMAP)
>
> Thanks
> 
Date:Mon, 6 Aug 2007 19:55:33 -0400   Author:  

Re: clipboard converts 8bpp to 32bpp   

>
> You can if you pass a handle created by CreateDIBSection
>
> " active"  wrote in message 
> news:u3w$Q9H2HHA.5884@TK2MSFTNGP02.phx.gbl...
>>

Trying to put a DibSection on the clipboard.
Guess I could use a little push.

I'm trying to use GetObject to fill in a DIBSECTION structure but don't know 
how to get a handle to my Bitmap.

In  CreateDIBSection I don't know what hDC to use.

To use SetClipboardData to pass the handle created by CreateDIBSection and 
don't know what format to use.

I'm guessing I can copy the data into the DibSection using BitBlt. Right?
Is there a better way?


Thanks for any suggestions
Date:Tue, 7 Aug 2007 21:08:54 -0400   Author:  

Re: clipboard converts 8bpp to 32bpp   
I do know about  Bitmap.GetHBITMAP(). I should not have included that below!

" active"  wrote in message 
news:OF3RxiV2HHA.484@TK2MSFTNGP06.phx.gbl...

> >
>> You can if you pass a handle created by CreateDIBSection
>>
>> " active"  wrote in message 
>> news:u3w$Q9H2HHA.5884@TK2MSFTNGP02.phx.gbl...
>>>
> Trying to put a DibSection on the clipboard.
> Guess I could use a little push.
>
> I'm trying to use GetObject to fill in a DIBSECTION structure but don't 
> know how to get a handle to my Bitmap.
>
> In  CreateDIBSection I don't know what hDC to use.
>
> To use SetClipboardData to pass the handle created by CreateDIBSection and 
> don't know what format to use.
>
> I'm guessing I can copy the data into the DibSection using BitBlt. Right?
> Is there a better way?
>
>
> Thanks for any suggestions
>
>
>
> 
Date:Wed, 8 Aug 2007 08:38:26 -0400   Author:  

Re: clipboard converts 8bpp to 32bpp   

> I'm trying to use GetObject to fill in a DIBSECTION structure but don't 
> know how to get a handle to my Bitmap.


CreateDIBSection returns a handle typed as a HBITMAP.


> In  CreateDIBSection I don't know what hDC to use.


1) Use GetDC(NULL) to return a hdc for the desktop.
2) Use CreateCompatibleDC to return a memory hdc.
3) Use the memory hdc with CreateDIBSection
4) Always release and delete device context resources when you are done with 
them.


> To use SetClipboardData to pass the handle created by CreateDIBSection and 
> don't know what format to use.


Use the CF_DIB format to place a global memory handle for the DIB itself.
You must construct a memory representation of the DIB.  Use GlobalAlloc.
The DIB's memory looks like:
BITMAPINFOHEADER
Color Table(palette)
DIB's bits

You may also use the clipboard format CF_BITMAP and place the DIB's HBITMAP 
on the clipboard.
If the DIB is indexed, you must place a handle(i.e., HPALETTE) for the DIB's 
palette on the clipboard.
Use CF_PALETTE clipboard format.

The last option is not to use SetClipboardData at all.  Use the preferred 
clipboard data transfer method, the IDataObject.
You can pass handles or com streams representing the DIB's clipboard data.

Use DataFormats.DeviceIndependentBitmap with
SetData to place a MemoryStream object that represents the DIB on the 
clipboard.


> I'm guessing I can copy the data into the DibSection using BitBlt. Right?
> Is there a better way?


BitBlt or any of the other GDI variations works.  You can also use Lockbits 
to transfer the data one scanline at a time.



" active"  wrote in message 
news:OF3RxiV2HHA.484@TK2MSFTNGP06.phx.gbl...

> >
>> You can if you pass a handle created by CreateDIBSection
>>
>> " active"  wrote in message 
>> news:u3w$Q9H2HHA.5884@TK2MSFTNGP02.phx.gbl...
>>>
> Trying to put a DibSection on the clipboard.
> Guess I could use a little push.
>
> I'm trying to use GetObject to fill in a DIBSECTION structure but don't 
> know how to get a handle to my Bitmap.
>
> In  CreateDIBSection I don't know what hDC to use.
>
> To use SetClipboardData to pass the handle created by CreateDIBSection and 
> don't know what format to use.
>
> I'm guessing I can copy the data into the DibSection using BitBlt. Right?
> Is there a better way?
>
>
> Thanks for any suggestions
>
>
>
> 
Date:Wed, 8 Aug 2007 10:03:00 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us