extragear/graphics/digikam

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

extragear/graphics/digikam

Gilles Caulier
SVN commit 485674 by cgilles:

digikam from trunk : printing image from showfoto and IE support 16 bits images.
TODO :
- Need to apply Printer ICC profile before prepare to print (Paco, this is job for you (:=))).
- Using Dimg method to prepare to pring image when it's possible.
CCMAIL: [hidden email], [hidden email]

 M  +2 -7      showfoto/showfoto.cpp  
 M  +15 -13    utilities/imageeditor/editor/imageprint.cpp  
 M  +10 -6     utilities/imageeditor/editor/imageprint.h  
 M  +2 -7      utilities/imageeditor/editor/imagewindow.cpp  


--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #485673:485674
@@ -1214,11 +1214,9 @@
 
 void ShowFoto::slotFilePrint()
 {
-    uint* data   = Digikam::DImgInterface::instance()->getData();
-    int   width  = Digikam::DImgInterface::instance()->origWidth();
-    int   height = Digikam::DImgInterface::instance()->origHeight();
+    Digikam::DImg image = Digikam::DImgInterface::instance()->getImage();
 
-    if (!data || !width || !height)
+    if (image.isNull())
         return;
 
     KPrinter printer;
@@ -1232,9 +1230,6 @@
 
     if ( printer.setup( this, i18n("Print %1").arg(printer.docName().section('/', -1)) ) )
     {
-        QImage image((uchar*)data, width, height, 32, 0, 0, QImage::IgnoreEndian);
-        image = image.copy();
-
         ImagePrint printOperations(image, printer, m_currentItem->url().filename());
         if (!printOperations.printImageWithQt())
         {
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imageprint.cpp #485673:485674
@@ -3,7 +3,7 @@
  * Date  : 2004-07-13
  * Description :
  *
- * Copyright 2004 by Gilles Caulier
+ * Copyright 2004-2005 by Gilles Caulier
  *
  * Original printing code from Kuickshow program.
  * Copyright (C) 2002 Carsten Pfeiffer <pfeiffer at kde.org>
@@ -66,7 +66,6 @@
 
 // Image printdialog class -------------------------------------------------------------
 
-
 ImageEditorPrintDialogPage::ImageEditorPrintDialogPage( QWidget *parent, const char *name )
                           : KPrintDialogPage( parent, name )
 {
@@ -103,7 +102,7 @@
     group->insert( m_scale );
     
     connect( m_scale, SIGNAL( toggled( bool )),
-             SLOT( toggleScaling( bool )));
+             this, SLOT( toggleScaling( bool )));
 
     m_units = new KComboBox( false, widget, "unit combobox" );
     grid->addWidget( m_units, 0, 2, AlignLeft );
@@ -184,10 +183,9 @@
 
 // Image print class -----------------------------------------------------------------
 
-ImagePrint::ImagePrint(QImage& image, KPrinter& printer,
+ImagePrint::ImagePrint(Digikam::DImg& image, KPrinter& printer,
                        const QString& filename)
-          : m_image( image ), m_printer( printer ),
-            m_filename( filename )
+          : m_image( image ), m_printer( printer ), m_filename( filename )
 {
 }
 
@@ -205,13 +203,18 @@
 
     QString t = "true";
     QString f = "false";
-    
+
+    // TODO : perform all prepare to print transformations using DImg methods.
+    // Paco, we will need to apply printer ICC profile here !
+
+    QImage image2Print = m_image.copyQImage();
+
     // Black & white print ?
     if ( m_printer.option( "app-imageeditor-blackwhite" ) != f)
     {
-        m_image = m_image.convertDepth( 1, Qt::MonoOnly |
-                                       Qt::ThresholdDither |
-                                       Qt::AvoidDither );
+        image2Print = image2Print.convertDepth( 1, Qt::MonoOnly |
+                                                Qt::ThresholdDither |
+                                                Qt::AvoidDither );
     }
 
     QPainter p;
@@ -226,7 +229,7 @@
     int w = metrics.width();
     int h = metrics.height();
 
-    QSize size = m_image.size();
+    QSize size = image2Print.size();
 
     bool printFilename = m_printer.option( "app-imageeditor-printFilename" ) != f;
     if ( printFilename )
@@ -297,7 +300,7 @@
         y = h - size.height();
 
     // Perform the actual drawing.
-    p.drawImage( QRect( x, y, size.width(), size.height()), m_image );;
+    p.drawImage( QRect( x, y, size.width(), size.height()), image2Print );
 
     if ( printFilename )
     {
@@ -317,7 +320,6 @@
     return true;
 }
 
-
 QString ImagePrint::minimizeString( QString text, const QFontMetrics& metrics,
                                     int maxWidth )
 {
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imageprint.h #485673:485674
@@ -3,7 +3,7 @@
  * Date  : 2004-07-13
  * Description :
  *
- * Copyright 2004 by Gilles Caulier
+ * Copyright 2004-2005 by Gilles Caulier
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -32,17 +32,21 @@
 #include <kprinter.h>
 #include <kdeprint/kprintdialogpage.h>
 
+// Digikam includes
+
+#include "dimg.h"
+
 class QCheckBox;
 class QRadioButton;
 
 class KComboBox;
 class KDoubleNumInput;
 
-class ImagePrint  
+class ImagePrint
 {
 public:
 
-    ImagePrint(QImage& image, KPrinter& printer,
+    ImagePrint(Digikam::DImg& image, KPrinter& printer,
                const QString& fileName);
     ~ImagePrint();
 
@@ -54,9 +58,9 @@
                             int maxWidth );                          
 private:
     
-    QImage    m_image;
-    KPrinter& m_printer;
-    QString   m_filename;
+    Digikam::DImg m_image;
+    KPrinter&     m_printer;
+    QString       m_filename;
     
 };
 
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imagewindow.cpp #485673:485674
@@ -944,11 +944,9 @@
 
 void ImageWindow::slotFilePrint()
 {
-    uint* data   = Digikam::DImgInterface::instance()->getData();
-    int   width  = Digikam::DImgInterface::instance()->origWidth();
-    int   height = Digikam::DImgInterface::instance()->origHeight();
+    Digikam::DImg image = Digikam::DImgInterface::instance()->getImage();
 
-    if (!data || !width || !height)
+    if (image.isNull())
         return;
 
     KPrinter printer;
@@ -962,9 +960,6 @@
 
     if ( printer.setup( this, i18n("Print %1").arg(printer.docName().section('/', -1)) ) )
     {
-        QImage image((uchar*)data, width, height, 32, 0, 0, QImage::IgnoreEndian);
-        image = image.copy();
-    
         ImagePrint printOperations(image, printer, m_urlCurrent.filename());
         if (!printOperations.printImageWithQt())
         {
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel