GdiPlusBitmap.h
上传用户:jinlangri
上传日期:2022-07-17
资源大小:10774k
文件大小:22k
源码类别:

GDI/图象编程

开发平台:

Visual C++

  1. /**************************************************************************
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp.  All Rights Reserved.
  4. *
  5. * Module Name:
  6. *
  7. *   GdiplusBitmap.h
  8. *
  9. * Abstract:
  10. *
  11. *   Bitmap related declarations
  12. *
  13. **************************************************************************/
  14. #ifndef _GDIPLUSBITMAP_H
  15. #define _GDIPLUSBITMAP_H
  16. // NOTE:
  17. //  Our current choice for the public API is to use constructors
  18. //  instead of static load functions to create image objects.
  19. //
  20. //  I've kept the static load functions here for now so that
  21. //  existing test programs are not broken. But they should
  22. //  eventually be taken out.
  23. #ifndef DCR_USE_NEW_140782
  24. inline 
  25. Image::Image(
  26.     IN const WCHAR* filename
  27.     )
  28. {
  29.     nativeImage = NULL;
  30.     lastResult = DllExports::GdipLoadImageFromFile(filename, &nativeImage);
  31. }
  32. inline 
  33. Image::Image(
  34.     IN IStream* stream
  35.     )
  36. {
  37.     nativeImage = NULL;
  38.     lastResult = DllExports::GdipLoadImageFromStream(stream, &nativeImage);
  39. }
  40. inline Image* 
  41. Image::FromFile(
  42.     IN const WCHAR* filename
  43.     )
  44. {
  45.     return new Image(filename);
  46. }
  47. inline Image*
  48. Image::FromStream(
  49.     IN IStream* stream
  50.     )
  51. {
  52.     return new Image(stream);
  53. }
  54. #else
  55. inline 
  56. Image::Image(
  57.     IN const WCHAR* filename,
  58.     IN BOOL useEmbeddedColorManagement
  59.     )
  60. {
  61.     nativeImage = NULL;
  62.     if(useEmbeddedColorManagement)
  63.     {
  64.         lastResult = DllExports::GdipLoadImageFromFileICM(
  65.             filename, 
  66.             &nativeImage
  67.         );
  68.     }
  69.     else
  70.     {      
  71.         lastResult = DllExports::GdipLoadImageFromFile(
  72.             filename, 
  73.             &nativeImage
  74.         );
  75.     }
  76. }
  77. inline 
  78. Image::Image(
  79.     IN IStream* stream,
  80.     IN BOOL useEmbeddedColorManagement
  81.     )
  82. {
  83.     nativeImage = NULL;
  84.     if(useEmbeddedColorManagement)
  85.     {
  86.         lastResult = DllExports::GdipLoadImageFromStreamICM(
  87.             stream, 
  88.             &nativeImage
  89.         );
  90.     }
  91.     else
  92.     {
  93.         lastResult = DllExports::GdipLoadImageFromStream(
  94.             stream, 
  95.             &nativeImage
  96.         );
  97.     }
  98. }
  99. inline Image* 
  100. Image::FromFile(
  101.     IN const WCHAR* filename,
  102.     IN BOOL useEmbeddedColorManagement
  103.     )
  104. {
  105.     return new Image(
  106.         filename, 
  107.         useEmbeddedColorManagement
  108.     );
  109. }
  110. inline Image*
  111. Image::FromStream(
  112.     IN IStream* stream,
  113.     IN BOOL useEmbeddedColorManagement
  114.     )
  115. {
  116.     return new Image(
  117.         stream,
  118.         useEmbeddedColorManagement
  119.     );
  120. }
  121. #endif
  122. inline 
  123. Image::~Image()
  124. {
  125.     DllExports::GdipDisposeImage(nativeImage);
  126. }
  127. inline Image* 
  128. Image::Clone() 
  129. {
  130.     GpImage *cloneimage = NULL;
  131.     SetStatus(DllExports::GdipCloneImage(nativeImage, &cloneimage));
  132.     return new Image(cloneimage, lastResult);
  133. }
  134. // Encorder Parameter
  135. inline UINT
  136. Image::GetEncoderParameterListSize(
  137.     IN const CLSID* clsidEncoder
  138.     ) 
  139. {
  140.     UINT size = 0;
  141.     SetStatus(DllExports::GdipGetEncoderParameterListSize(nativeImage,
  142.                                                           clsidEncoder,
  143.                                                           &size));
  144.     return size;
  145. }
  146. inline Status
  147. Image::GetEncoderParameterList(
  148.     IN const CLSID* clsidEncoder,
  149.     IN UINT size,
  150.     OUT EncoderParameters* buffer
  151.     )
  152. {
  153.     return SetStatus(DllExports::GdipGetEncoderParameterList(nativeImage,
  154.                                                              clsidEncoder,
  155.                                                              size,
  156.                                                              buffer));
  157. }
  158. // Save images
  159. inline Status
  160. Image::Save(
  161.     IN const WCHAR* filename,
  162.     IN const CLSID* clsidEncoder,
  163.     IN const EncoderParameters *encoderParams
  164.     )
  165. {
  166.     return SetStatus(DllExports::GdipSaveImageToFile(nativeImage,
  167.                                                      filename,
  168.                                                      clsidEncoder,
  169.                                                      encoderParams));
  170. }
  171. inline Status
  172. Image::Save(
  173.     IN IStream* stream,
  174.     IN const CLSID* clsidEncoder,
  175.     IN const EncoderParameters *encoderParams
  176.     )
  177. {
  178.     return SetStatus(DllExports::GdipSaveImageToStream(nativeImage,
  179.                                                        stream,
  180.                                                        clsidEncoder,
  181.                                                        encoderParams));
  182. }
  183. inline Status
  184. Image::SaveAdd(
  185.     IN const EncoderParameters *encoderParams
  186.     )
  187. {
  188.     return SetStatus(DllExports::GdipSaveAdd(nativeImage,
  189.                                              encoderParams));
  190. }
  191. inline Status
  192. Image::SaveAdd(
  193.     IN Image* newImage,
  194.     IN const EncoderParameters *encoderParams
  195.     )
  196. {
  197.     if ( newImage == NULL )
  198.     {
  199.         return SetStatus(InvalidParameter);
  200.     }
  201.     return SetStatus(DllExports::GdipSaveAddImage(nativeImage,
  202.                                                   newImage->nativeImage,
  203.                                                   encoderParams));
  204. }
  205. // Get size and type information
  206. inline ImageType 
  207. Image::GetType() const
  208. {
  209.     ImageType type = ImageTypeUnknown;
  210.     SetStatus(DllExports::GdipGetImageType(nativeImage, &type));
  211.     return type;
  212. }
  213. inline Status 
  214. Image::GetPhysicalDimension(
  215.     OUT SizeF* size
  216.     ) 
  217. {
  218.     if (size == NULL) 
  219.     {
  220.         return SetStatus(InvalidParameter);
  221.     }
  222.     
  223.     REAL width, height;
  224.     Status status;
  225.     status = SetStatus(DllExports::GdipGetImageDimension(nativeImage,
  226.                                                          &width, &height));
  227.     size->Width  = width;
  228.     size->Height = height;
  229.     return status;
  230. }
  231. inline Status 
  232. Image::GetBounds(
  233.     OUT RectF *srcRect, 
  234.     OUT Unit *srcUnit
  235.     )
  236. {
  237.     return SetStatus(DllExports::GdipGetImageBounds(nativeImage,
  238.                                                     srcRect, srcUnit));
  239. }
  240. inline UINT 
  241. Image::GetWidth()
  242. {
  243.     UINT width = 0;
  244.     SetStatus(DllExports::GdipGetImageWidth(nativeImage, &width));
  245.     return width;
  246. }
  247. inline UINT 
  248. Image::GetHeight()
  249. {
  250.     UINT height = 0;
  251.     SetStatus(DllExports::GdipGetImageHeight(nativeImage, &height));
  252.     return height;
  253. }
  254. inline REAL 
  255. Image::GetHorizontalResolution()
  256. {
  257.     REAL resolution = 0.0f;
  258.     SetStatus(DllExports::GdipGetImageHorizontalResolution(nativeImage, &resolution));
  259.     return resolution;
  260. }
  261. inline REAL 
  262. Image::GetVerticalResolution()
  263. {
  264.     REAL resolution = 0.0f;
  265.     SetStatus(DllExports::GdipGetImageVerticalResolution(nativeImage, &resolution));
  266.     return resolution;
  267. }
  268. inline UINT 
  269. Image::GetFlags()
  270. {
  271.     UINT flags = 0;
  272.     SetStatus(DllExports::GdipGetImageFlags(nativeImage, &flags));
  273.     return flags;
  274. }
  275. inline Status 
  276. Image::GetRawFormat(OUT GUID *format)
  277. {
  278.     return SetStatus(DllExports::GdipGetImageRawFormat(nativeImage, format));
  279. }
  280. inline PixelFormat 
  281. Image::GetPixelFormat()
  282. {
  283.     PixelFormat format;
  284.     SetStatus(DllExports::GdipGetImagePixelFormat(nativeImage, &format));
  285.     return format;
  286. }
  287. inline INT 
  288. Image::GetPaletteSize()
  289. {
  290.     INT size = 0;
  291.     
  292.     SetStatus(DllExports::GdipGetImagePaletteSize(nativeImage, &size));
  293.     
  294.     return size;
  295. }
  296. inline Status 
  297. Image::GetPalette(
  298.     OUT ColorPalette *palette,
  299.     IN INT size
  300. )
  301. {
  302.     return SetStatus(DllExports::GdipGetImagePalette(nativeImage, palette, size));
  303. }
  304. inline Status 
  305. Image::SetPalette(
  306.     IN const ColorPalette *palette
  307.     )
  308. {
  309.     return SetStatus(DllExports::GdipSetImagePalette(nativeImage, palette));
  310. }
  311. // Thumbnail support
  312. inline Image* 
  313. Image::GetThumbnailImage(
  314.     IN UINT thumbWidth,
  315.     IN UINT thumbHeight,
  316.     IN GetThumbnailImageAbort callback,
  317.     IN VOID* callbackData
  318.     )
  319. {
  320.     GpImage *thumbimage = NULL;
  321.     SetStatus(DllExports::GdipGetImageThumbnail(nativeImage,
  322.                                                 thumbWidth, thumbHeight,
  323.                                                 &thumbimage,
  324.                                                 callback, callbackData));
  325.     Image *newImage = new Image(thumbimage, lastResult);
  326.     if (newImage == NULL) 
  327.     {
  328.         DllExports::GdipDisposeImage(thumbimage);
  329.     }
  330.     return newImage;
  331. }
  332. // Multi-frame support
  333. inline UINT 
  334. Image::GetFrameDimensionsCount()
  335. {
  336.     UINT count = 0;
  337.     SetStatus(DllExports::GdipImageGetFrameDimensionsCount(nativeImage,
  338.                                                                   &count));
  339.     return count;
  340. }
  341. inline Status 
  342. Image::GetFrameDimensionsList(
  343.     OUT GUID* dimensionIDs, 
  344.     IN UINT count
  345.     )
  346. {
  347.     return SetStatus(DllExports::GdipImageGetFrameDimensionsList(nativeImage,
  348.                                                                  dimensionIDs,
  349.                                                                  count));
  350. }
  351. inline UINT 
  352. Image::GetFrameCount(
  353.     IN const GUID* dimensionID
  354.     )
  355. {
  356.     UINT count = 0;
  357.     SetStatus(DllExports::GdipImageGetFrameCount(nativeImage,
  358.                                                         dimensionID,
  359.                                                         &count));
  360.     return count;
  361. }
  362. inline Status 
  363. Image::SelectActiveFrame(
  364.     IN const GUID *dimensionID, 
  365.     IN UINT frameIndex
  366.     )
  367. {
  368.     return SetStatus(DllExports::GdipImageSelectActiveFrame(nativeImage,
  369.                                                             dimensionID,
  370.                                                             frameIndex));
  371. }
  372. inline Status
  373. Image::RotateFlip(
  374.     IN RotateFlipType rotateFlipType
  375.     )
  376. {
  377.     return SetStatus(DllExports::GdipImageRotateFlip(nativeImage,
  378.                                                      rotateFlipType));
  379. }
  380. // Image property related functions
  381. inline UINT 
  382. Image::GetPropertyCount()
  383. {
  384.     UINT numProperty = 0;
  385.     SetStatus(DllExports::GdipGetPropertyCount(nativeImage,
  386.                                                &numProperty));
  387.     return numProperty;
  388. }
  389. inline Status 
  390. Image::GetPropertyIdList(
  391.     IN UINT numOfProperty, 
  392.     OUT PROPID* list
  393.     )
  394. {
  395.     return SetStatus(DllExports::GdipGetPropertyIdList(nativeImage,
  396.                                                        numOfProperty, list));
  397. }
  398.     
  399. inline UINT 
  400. Image::GetPropertyItemSize(
  401.     IN PROPID propId
  402.     )
  403. {
  404.     UINT size = 0;
  405.     SetStatus(DllExports::GdipGetPropertyItemSize(nativeImage,
  406.                                                   propId,
  407.                                                   &size));
  408.     return size;
  409. }
  410. inline Status 
  411. Image::GetPropertyItem(
  412.     IN PROPID propId, 
  413.     IN UINT propSize,
  414.     OUT PropertyItem* buffer
  415.     )
  416. {
  417.     return SetStatus(DllExports::GdipGetPropertyItem(nativeImage,
  418.                                                      propId, propSize, buffer));
  419. }
  420. inline Status 
  421. Image::GetPropertySize(
  422.     OUT UINT* totalBufferSize, 
  423.     OUT UINT* numProperties
  424.     )
  425. {
  426.     return SetStatus(DllExports::GdipGetPropertySize(nativeImage,
  427.                                                      totalBufferSize,
  428.                                                      numProperties));
  429. }
  430. inline Status 
  431. Image::GetAllPropertyItems(
  432.     IN UINT totalBufferSize,
  433.     IN UINT numProperties,
  434.     OUT PropertyItem* allItems
  435.     )
  436. {
  437.     if (allItems == NULL) 
  438.     {
  439.         return SetStatus(InvalidParameter);
  440.     }
  441.     return SetStatus(DllExports::GdipGetAllPropertyItems(nativeImage,
  442.                                                          totalBufferSize,
  443.                                                          numProperties,
  444.                                                          allItems));
  445. }
  446. inline Status 
  447. Image::RemovePropertyItem(
  448.     IN PROPID propId
  449.     )
  450. {
  451.     return SetStatus(DllExports::GdipRemovePropertyItem(nativeImage, propId));
  452. }
  453. inline Status 
  454. Image::SetPropertyItem(
  455.     IN const PropertyItem* item
  456.     )
  457. {
  458.     return SetStatus(DllExports::GdipSetPropertyItem(nativeImage, item));
  459. }
  460. // Get/SetLayout
  461. // Support for Middle East localization (right-to-left mirroring)
  462. inline ImageLayout
  463. Image::GetLayout() const
  464. {
  465.     ImageLayout layout;
  466.     SetStatus(DllExports::GdipGetImageLayout(nativeImage, &layout));
  467.     return layout;
  468. }
  469. inline Status
  470. Image::SetLayout(IN const ImageLayout layout)
  471. {
  472.     return SetStatus(
  473.         DllExports::GdipSetImageLayout(nativeImage, layout)
  474.     );
  475. }
  476. inline Status
  477. Image::GetLastStatus() const
  478. {
  479.     Status lastStatus = lastResult;
  480.     lastResult = Ok;
  481.     return lastStatus;
  482. }
  483. inline 
  484. Image::Image(GpImage *nativeImage, Status status)
  485. {
  486.     SetNativeImage(nativeImage);
  487.     lastResult = status;
  488. }
  489. inline VOID 
  490. Image::SetNativeImage(GpImage *nativeImage)
  491. {
  492.     this->nativeImage = nativeImage;
  493. }
  494. inline 
  495. Bitmap::Bitmap(
  496.     IN const WCHAR *filename, 
  497.     IN BOOL useEmbeddedColorManagement
  498.     )
  499. {
  500.     GpBitmap *bitmap = NULL;
  501.     if(useEmbeddedColorManagement) 
  502.     {
  503.         lastResult = DllExports::GdipCreateBitmapFromFileICM(filename, &bitmap);
  504.     }
  505.     else
  506.     {
  507.         lastResult = DllExports::GdipCreateBitmapFromFile(filename, &bitmap);
  508.     }
  509.     SetNativeImage(bitmap);
  510. }
  511. inline 
  512. Bitmap::Bitmap(
  513.     IN IStream *stream, 
  514.     IN BOOL useEmbeddedColorManagement
  515.     )
  516. {
  517.     GpBitmap *bitmap = NULL;
  518.     if(useEmbeddedColorManagement)
  519.     {
  520.         lastResult = DllExports::GdipCreateBitmapFromStreamICM(stream, &bitmap);
  521.     }
  522.     else
  523.     {
  524.         lastResult = DllExports::GdipCreateBitmapFromStream(stream, &bitmap);
  525.     }
  526.     SetNativeImage(bitmap);
  527. }
  528. inline
  529. Bitmap::Bitmap(
  530.     IN INT width,
  531.     IN INT height,
  532.     IN INT stride,
  533.     IN PixelFormat format,
  534.     IN BYTE *scan0
  535.     )
  536. {
  537.     GpBitmap *bitmap = NULL;
  538.     lastResult = DllExports::GdipCreateBitmapFromScan0(width,
  539.                                                        height,
  540.                                                        stride,
  541.                                                        format,
  542.                                                        scan0,
  543.                                                        &bitmap);
  544.     SetNativeImage(bitmap);
  545. }
  546. inline 
  547. Bitmap::Bitmap(
  548.     IN INT width,
  549.     IN INT height,
  550.     IN PixelFormat format
  551.     )
  552. {
  553.     GpBitmap *bitmap = NULL;
  554.     lastResult = DllExports::GdipCreateBitmapFromScan0(width,
  555.                                                        height,
  556.                                                        0,
  557.                                                        format,
  558.                                                        NULL,
  559.                                                        &bitmap);
  560.     SetNativeImage(bitmap);
  561. }
  562. inline
  563. Bitmap::Bitmap(
  564.     IN INT width, 
  565.     IN INT height, 
  566.     IN Graphics* target)
  567. {
  568.     GpBitmap *bitmap = NULL;
  569.     lastResult = DllExports::GdipCreateBitmapFromGraphics(width,
  570.                                                           height,
  571.                                                           target->nativeGraphics,
  572.                                                           &bitmap);
  573.     SetNativeImage(bitmap);
  574. }
  575. inline 
  576. Bitmap::Bitmap(
  577.     IN IDirectDrawSurface7 * surface
  578.     )
  579. {
  580.     GpBitmap *bitmap = NULL;
  581.     lastResult = DllExports::GdipCreateBitmapFromDirectDrawSurface(surface,
  582.                                                        &bitmap);
  583.     SetNativeImage(bitmap);
  584. }
  585. inline 
  586. Bitmap::Bitmap(
  587.     IN const BITMAPINFO* gdiBitmapInfo, 
  588.     IN VOID* gdiBitmapData
  589.     )
  590. {
  591.     GpBitmap *bitmap = NULL;
  592.     lastResult = DllExports::GdipCreateBitmapFromGdiDib(gdiBitmapInfo,
  593.                                                         gdiBitmapData,
  594.                                                         &bitmap);
  595.     SetNativeImage(bitmap);
  596. }
  597. inline 
  598. Bitmap::Bitmap(
  599.     IN HBITMAP hbm, 
  600.     IN HPALETTE hpal
  601.     )
  602. {
  603.     GpBitmap *bitmap = NULL;
  604.     lastResult = DllExports::GdipCreateBitmapFromHBITMAP(hbm, hpal, &bitmap);
  605.     SetNativeImage(bitmap);
  606. }
  607. inline 
  608. Bitmap::Bitmap(
  609.     IN HICON hicon
  610.     )
  611. {
  612.     GpBitmap *bitmap = NULL;
  613.     lastResult = DllExports::GdipCreateBitmapFromHICON(hicon, &bitmap);
  614.     SetNativeImage(bitmap);
  615. }
  616. inline 
  617. Bitmap::Bitmap(
  618.     IN HINSTANCE hInstance, 
  619.     IN const WCHAR *bitmapName
  620.     )
  621. {
  622.     GpBitmap *bitmap = NULL;
  623.     lastResult = DllExports::GdipCreateBitmapFromResource(hInstance,
  624.                                                           bitmapName,
  625.                                                           &bitmap);
  626.     SetNativeImage(bitmap);
  627. }
  628. inline Bitmap* 
  629. Bitmap::FromFile(
  630.     IN const WCHAR *filename,
  631.     IN BOOL useEmbeddedColorManagement
  632.     )
  633. {
  634.     return new Bitmap(
  635.         filename, 
  636.         useEmbeddedColorManagement
  637.     );
  638. }
  639. inline Bitmap* 
  640. Bitmap::FromStream(
  641.     IN IStream *stream,
  642.     IN BOOL useEmbeddedColorManagement
  643.     )
  644. {
  645.     return new Bitmap(
  646.         stream, 
  647.         useEmbeddedColorManagement
  648.     );
  649. }
  650. inline Bitmap* 
  651. Bitmap::FromDirectDrawSurface7(
  652.     IN IDirectDrawSurface7* surface
  653.     )
  654. {
  655.     return new Bitmap(surface);
  656. }
  657. inline Bitmap* 
  658. Bitmap::FromBITMAPINFO(
  659.     IN const BITMAPINFO* gdiBitmapInfo, 
  660.     IN VOID* gdiBitmapData)
  661. {
  662.     return new Bitmap(gdiBitmapInfo, gdiBitmapData);
  663. }
  664. inline Bitmap* 
  665. Bitmap::FromHBITMAP(
  666.     IN HBITMAP hbm, 
  667.     IN HPALETTE hpal
  668.     )
  669. {
  670.     return new Bitmap(hbm, hpal);
  671. }
  672. inline Bitmap* 
  673. Bitmap::FromHICON(
  674.     IN HICON hicon
  675.     )
  676. {
  677.     return new Bitmap(hicon);
  678. }
  679. inline Bitmap* 
  680. Bitmap::FromResource(
  681.     IN HINSTANCE hInstance, 
  682.     IN const WCHAR *bitmapName)
  683. {
  684.     return new Bitmap(hInstance, bitmapName);
  685. }
  686. inline Status 
  687. Bitmap::GetHBITMAP(
  688.     IN const Color& colorBackground,
  689.     OUT HBITMAP* hbmReturn
  690.     )
  691. {
  692.     return SetStatus(DllExports::GdipCreateHBITMAPFromBitmap(
  693.                                         static_cast<GpBitmap*>(nativeImage),
  694.                                         hbmReturn,
  695.                                         colorBackground.GetValue()));
  696. }
  697. inline Status 
  698. Bitmap::GetHICON(
  699.     OUT HICON* hiconReturn
  700.     )
  701. {
  702.     return SetStatus(DllExports::GdipCreateHICONFromBitmap(
  703.                                         static_cast<GpBitmap*>(nativeImage),
  704.                                         hiconReturn));
  705. }
  706. inline Bitmap* 
  707. Bitmap::Clone(
  708.     IN const Rect& rect,
  709.     IN PixelFormat format
  710.     )
  711. {
  712.     return Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
  713. }
  714. inline Bitmap* 
  715. Bitmap::Clone(
  716.     IN INT x,
  717.     IN INT y,
  718.     IN INT width,
  719.     IN INT height,
  720.     IN PixelFormat format
  721.     )
  722. {
  723.    GpBitmap* gpdstBitmap = NULL;
  724.    Bitmap* bitmap;
  725.    lastResult = DllExports::GdipCloneBitmapAreaI(
  726.                                x,
  727.                                y,
  728.                                width,
  729.                                height,
  730.                                format,
  731.                                (GpBitmap *)nativeImage,
  732.                                &gpdstBitmap);
  733.    if (lastResult == Ok)
  734.    {
  735.        bitmap = new Bitmap(gpdstBitmap);
  736.        if (bitmap == NULL) 
  737.        {
  738.            DllExports::GdipDisposeImage(gpdstBitmap);
  739.        }
  740.        return bitmap;
  741.    }
  742.    else
  743.        return NULL;
  744. }
  745. inline Bitmap* 
  746. Bitmap::Clone(
  747.     IN const RectF& rect,
  748.     IN PixelFormat format
  749.     )
  750. {
  751.     return Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
  752. }
  753. inline Bitmap*
  754. Bitmap::Clone(
  755.     IN REAL x,
  756.     IN REAL y,
  757.     IN REAL width,
  758.     IN REAL height,
  759.     IN PixelFormat format
  760.     )
  761. {
  762.    GpBitmap* gpdstBitmap = NULL;
  763.    Bitmap* bitmap;
  764.    SetStatus(DllExports::GdipCloneBitmapArea(
  765.                                x,
  766.                                y,
  767.                                width,
  768.                                height,
  769.                                format,
  770.                                (GpBitmap *)nativeImage,
  771.                                &gpdstBitmap));
  772.    if (lastResult == Ok)
  773.    {
  774.        bitmap = new Bitmap(gpdstBitmap);
  775.        if (bitmap == NULL) 
  776.        {
  777.            DllExports::GdipDisposeImage(gpdstBitmap);
  778.        }
  779.        return bitmap;
  780.    }
  781.    else
  782.        return NULL;
  783. }
  784. inline Bitmap::Bitmap(GpBitmap *nativeBitmap)
  785. {
  786.     lastResult = Ok;
  787.     SetNativeImage(nativeBitmap);
  788. }
  789. inline Status
  790. Bitmap::LockBits(
  791.     IN const Rect& rect,
  792.     IN UINT flags,
  793.     IN PixelFormat format,
  794.     OUT BitmapData* lockedBitmapData
  795. )
  796. {
  797.     return SetStatus(DllExports::GdipBitmapLockBits(
  798.                                     static_cast<GpBitmap*>(nativeImage),
  799.                                     &rect,
  800.                                     flags,
  801.                                     format,
  802.                                     lockedBitmapData));
  803. }
  804. inline Status 
  805. Bitmap::UnlockBits(
  806.     IN BitmapData* lockedBitmapData
  807.     )
  808. {
  809.     return SetStatus(DllExports::GdipBitmapUnlockBits(
  810.                                     static_cast<GpBitmap*>(nativeImage),
  811.                                     lockedBitmapData));
  812. }
  813. inline Status 
  814. Bitmap::GetPixel(
  815.     IN INT x, 
  816.     IN INT y, 
  817.     OUT Color *color) 
  818. {
  819.     ARGB argb;
  820.     Status status = SetStatus(DllExports::GdipBitmapGetPixel(
  821.         static_cast<GpBitmap *>(nativeImage),
  822.         x, y,        
  823.         &argb));
  824.     if (status == Ok) 
  825.     {
  826.         color->SetValue(argb);
  827.     }
  828.     return  status;
  829. }
  830. inline Status 
  831. Bitmap::SetPixel(
  832.     IN INT x, 
  833.     IN INT y, 
  834.     IN const Color& color) 
  835. {
  836.     return SetStatus(DllExports::GdipBitmapSetPixel(
  837.         static_cast<GpBitmap *>(nativeImage),
  838.         x, y,
  839.         color.GetValue()));
  840. }
  841. inline Status 
  842. Bitmap::SetResolution(
  843.     IN REAL xdpi, 
  844.     IN REAL ydpi)
  845. {
  846.     return SetStatus(DllExports::GdipBitmapSetResolution(
  847.         static_cast<GpBitmap *>(nativeImage),
  848.         xdpi, ydpi));
  849. }
  850. #endif