2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-01-23 00:53:32 +03:00
|
|
|
|
2013-12-16 04:00:54 +04:00
|
|
|
#ifndef nsImageClipboard_h
|
|
|
|
#define nsImageClipboard_h
|
|
|
|
|
2001-01-23 00:53:32 +03:00
|
|
|
/* Things To Do 11/8/00
|
|
|
|
|
|
|
|
Check image metrics, can we support them? Do we need to?
|
|
|
|
Any other render format? HTML?
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2003-10-08 00:39:25 +04:00
|
|
|
#include "nsError.h"
|
2001-01-23 03:28:36 +03:00
|
|
|
#include <windows.h>
|
2001-01-23 00:53:32 +03:00
|
|
|
|
2001-01-23 03:28:36 +03:00
|
|
|
#include "nsCOMPtr.h"
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 05:50:15 +04:00
|
|
|
#include "imgIContainer.h"
|
2006-09-13 23:52:44 +04:00
|
|
|
#include "nsIInputStream.h"
|
2001-01-23 00:53:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// nsImageToClipboard
|
|
|
|
//
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 05:50:15 +04:00
|
|
|
// A utility class that takes an imgIContainer and does all the bitmap magic
|
2001-01-23 00:53:32 +03:00
|
|
|
// to allow us to put it on the clipboard
|
|
|
|
//
|
|
|
|
class nsImageToClipboard
|
|
|
|
{
|
|
|
|
public:
|
2012-09-07 06:48:16 +04:00
|
|
|
nsImageToClipboard(imgIContainer* aInImage, bool aWantDIBV5 = true);
|
2001-01-23 00:53:32 +03:00
|
|
|
~nsImageToClipboard();
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
// Call to get the actual bits that go on the clipboard. If |nullptr|, the
|
2001-01-23 00:53:32 +03:00
|
|
|
// setup operations have failed.
|
|
|
|
//
|
2001-03-27 10:02:54 +04:00
|
|
|
// NOTE: The caller owns the handle and must delete it with ::GlobalRelease()
|
2001-01-23 00:53:32 +03:00
|
|
|
nsresult GetPicture ( HANDLE* outBits ) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Computes # of bytes needed by a bitmap with the specified attributes.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t CalcSize(int32_t aHeight, int32_t aColors, WORD aBitsPerPixel, int32_t aSpanBytes);
|
|
|
|
int32_t CalcSpanLength(uint32_t aWidth, uint32_t aBitCount);
|
2001-01-23 00:53:32 +03:00
|
|
|
|
|
|
|
// Do the work
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 05:50:15 +04:00
|
|
|
nsresult CreateFromImage ( imgIContainer* inImage, HANDLE* outBitmap );
|
2001-01-23 00:53:32 +03:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 05:50:15 +04:00
|
|
|
nsCOMPtr<imgIContainer> mImage; // the image we're working with
|
2012-09-07 06:48:16 +04:00
|
|
|
bool mWantDIBV5;
|
2001-01-23 00:53:32 +03:00
|
|
|
|
|
|
|
}; // class nsImageToClipboard
|
|
|
|
|
|
|
|
|
2006-09-13 23:52:44 +04:00
|
|
|
struct bitFields {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t red;
|
|
|
|
uint32_t green;
|
|
|
|
uint32_t blue;
|
|
|
|
uint8_t redLeftShift;
|
|
|
|
uint8_t redRightShift;
|
|
|
|
uint8_t greenLeftShift;
|
|
|
|
uint8_t greenRightShift;
|
|
|
|
uint8_t blueLeftShift;
|
|
|
|
uint8_t blueRightShift;
|
2006-09-13 23:52:44 +04:00
|
|
|
};
|
|
|
|
|
2001-01-23 00:53:32 +03:00
|
|
|
//
|
|
|
|
// nsImageFromClipboard
|
|
|
|
//
|
|
|
|
// A utility class that takes a DIB from the win32 clipboard and does
|
2006-09-13 23:52:44 +04:00
|
|
|
// all the bitmap magic to convert it to a PNG or a JPEG in the form of a nsIInputStream
|
2001-01-23 00:53:32 +03:00
|
|
|
//
|
|
|
|
class nsImageFromClipboard
|
|
|
|
{
|
|
|
|
public:
|
2006-09-13 23:52:44 +04:00
|
|
|
nsImageFromClipboard () ;
|
2001-01-23 00:53:32 +03:00
|
|
|
~nsImageFromClipboard ( ) ;
|
|
|
|
|
|
|
|
// Retrieve the newly created image
|
2008-10-20 19:21:02 +04:00
|
|
|
nsresult GetEncodedImageStream (unsigned char * aClipboardData, const char * aMIMEFormat, nsIInputStream** outImage);
|
2001-01-23 00:53:32 +03:00
|
|
|
|
2006-09-13 23:52:44 +04:00
|
|
|
private:
|
2001-01-23 00:53:32 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void InvertRows(unsigned char * aInitialBuffer, uint32_t aSizeOfBuffer, uint32_t aNumBytesPerRow);
|
2006-09-13 23:52:44 +04:00
|
|
|
nsresult ConvertColorBitMap(unsigned char * aInputBuffer, PBITMAPINFO pBitMapInfo, unsigned char * aOutBuffer);
|
2012-08-22 19:56:38 +04:00
|
|
|
void CalcBitmask(uint32_t aMask, uint8_t& aBegin, uint8_t& aLength);
|
2006-09-13 23:52:44 +04:00
|
|
|
void CalcBitShift(bitFields * aColorMask);
|
2001-01-23 00:53:32 +03:00
|
|
|
|
|
|
|
}; // nsImageFromClipboard
|
2013-12-16 04:00:54 +04:00
|
|
|
|
|
|
|
#endif
|