User Tag List

Results 1 to 4 of 4

Thread: cSurface <-> Clipboard

  1. #1
    Clicker Fusion 2.5 DeveloperSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,739
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    cSurface <-> Clipboard

    Hey there. I could need some help with my Surface object.
    I've been trying to implement clipboard input and output in my extension.
    It does seem to work, but the image is distorted. The color channels are swapped, and the image is about 1 pixel off.
    I guess that's because I'm missing something like a +1 for a memory address, however I'm more or less clueless.

    Here's the save function. It's a little shorter than the load one, and I think it's enough for now.
    Thanks for any input

    PHP Code:
    if(OpenClipboard(NULL))
    {
        
    EmptyClipboard();
        
    //Loads a surface from a vector in the rdPtr
        
    cSurfacetmp Image(img);
        
    //Allocate buffer
        
    HGLOBAL cb GlobalAlloc(GMEM_MOVEABLE,tmp->GetDIBSize());
        
    BITMAPINFObmp = (BITMAPINFO*)GlobalLock(cb);
        
    //Copy image
        
    tmp->SaveImage(bmp,(BYTE*)(bmp+1));
        
    SetClipboardData(CF_DIB,bmp);
        
    //Done
        
    GlobalUnlock(cb);
        
    CloseClipboard();

    Left: Source, Right: Clipboard

  2. #2
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: cSurface <-> Clipboard

    It seems like the image data is one byte off, causing the colors to rotate. What parameters does SaveImage take? I suspect the error might have to do with the (bmp+1) part.

  3. #3
    Clicker Fusion 2.5 DeveloperSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,739
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: cSurface <-> Clipboard

    Hey, thanks for your reply.
    That was my guess and I tried it before.
    I just tried it again just to make sure, but when I did it, I only tried to add one. Ouch. And indeed, subtracting one byte fixed the problem. Thanks. :blush:

  4. #4
    Clicker Fusion 2.5 DeveloperSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,739
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: cSurface <-> Clipboard

    Hello, with that method I was still having problems sometimes.
    I just discovered the perfect solution - There actually is a function to get the header size.

    So you can use this code:
    Surface->LoadImage(Bitmap,GetDIBBitmap(Bitmap))
    Bitmap being an LPBITMAPINFO.

Similar Threads

  1. CSurface documentation
    By Phi in forum Extension Development
    Replies: 2
    Last Post: 11th December 2012, 02:31 PM
  2. HDC Text Equivalents on cSurface?
    By LIJI in forum Extension Developers Lobby
    Replies: 1
    Last Post: 15th February 2009, 06:06 PM
  3. converting cSurface to HBITMAP
    By Looki in forum Extension Developers Lobby
    Replies: 3
    Last Post: 8th November 2008, 08:56 PM
  4. [help] Drawing a polygon on cSurface
    By Bornemix in forum Extension Development
    Replies: 1
    Last Post: 21st October 2008, 01:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •