ctkWidgetsUtils.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkWidgetsUtils_h
  15. #define __ctkWidgetsUtils_h
  16. // Qt includes
  17. #include <QString>
  18. #include <QRect>
  19. class QImage;
  20. #include "ctkWidgetsExport.h"
  21. namespace ctk {
  22. ///
  23. /// \ingroup Widgets
  24. /// Create a base 64 image tag. Can be used that way:
  25. /// QString("<img src=\"%1\">").arg(base64HTMLImageTagSrc(myImage);
  26. QString CTK_WIDGETS_EXPORT base64HTMLImageTagSrc(const QImage& image);
  27. ///
  28. /// \ingroup Widgets
  29. /// Grab the contents of a QWidget and all its children.
  30. /// Handle correctly the case of QGLWidgets.
  31. /// \sa QWidget::grab
  32. QImage CTK_WIDGETS_EXPORT grabWidget(QWidget* widget, QRect rectangle = QRect());
  33. ///
  34. /// \ingroup Widgets
  35. /// Convert an KWidget encoded image into a QImage
  36. /// The data can be base64 encoded and/or zlib compressed.
  37. QImage CTK_WIDGETS_EXPORT kwIconToQImage(const unsigned char *data, int width, int height, int pixelSize, unsigned int bufferLength, int options = 0);
  38. }
  39. #endif