working new borders for bigger profile images bigger_images
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Fri, 28 May 2010 13:11:25 +0000 (16:11 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Fri, 28 May 2010 13:11:25 +0000 (16:11 +0300)
14 files changed:
images.qrc
res/images/large_profile_pic_border_bottom_filler.png [new file with mode: 0644]
res/images/large_profile_pic_border_bottom_left.png [new file with mode: 0644]
res/images/large_profile_pic_border_bottom_right.png [new file with mode: 0644]
res/images/large_profile_pic_border_left.png [new file with mode: 0755]
res/images/large_profile_pic_border_middle.png [new file with mode: 0755]
res/images/large_profile_pic_border_right.png [new file with mode: 0755]
res/images/large_profile_pic_border_side_filler.png [new file with mode: 0644]
res/images/large_profile_pic_border_top_filler.png [new file with mode: 0644]
res/images/large_profile_pic_border_top_left.png [new file with mode: 0644]
res/images/large_profile_pic_border_top_right.png [new file with mode: 0644]
src/situareservice/situarecommon.h
src/situareservice/situareservice.cpp
src/ui/avatarimage.cpp

index 5d39858..0aad3c5 100644 (file)
@@ -23,7 +23,7 @@
         <file>res/images/list_item_bottom.png</file>
         <file>res/images/list_item_middle.png</file>
         <file>res/images/list_item_top.png</file>
-           <file>res/images/user_info_item_bottom.png</file>
+        <file>res/images/user_info_item_bottom.png</file>
         <file>res/images/user_info_item_middle.png</file>
         <file>res/images/user_info_item_top.png</file>
         <file>res/images/sliding_bar_left_test.png</file>
         <file>res/images/rocket_icon_gray.png</file>
         <file>res/images/walk_icon_gray.png</file>
         <file>res/images/profile_pic_border.png</file>
+        <file>res/images/large_profile_pic_border_left.png</file>
+        <file>res/images/large_profile_pic_border_middle.png</file>
+        <file>res/images/large_profile_pic_border_right.png</file>
+        <file>res/images/large_profile_pic_border_bottom_filler.png</file>
+        <file>res/images/large_profile_pic_border_side_filler.png</file>
+        <file>res/images/large_profile_pic_border_top_filler.png</file>
+        <file>res/images/large_profile_pic_border_top_left.png</file>
+        <file>res/images/large_profile_pic_border_top_right.png</file>
+        <file>res/images/large_profile_pic_border_bottom_left.png</file>
+        <file>res/images/large_profile_pic_border_bottom_right.png</file>
     </qresource>
 </RCC>
diff --git a/res/images/large_profile_pic_border_bottom_filler.png b/res/images/large_profile_pic_border_bottom_filler.png
new file mode 100644 (file)
index 0000000..3a1db41
Binary files /dev/null and b/res/images/large_profile_pic_border_bottom_filler.png differ
diff --git a/res/images/large_profile_pic_border_bottom_left.png b/res/images/large_profile_pic_border_bottom_left.png
new file mode 100644 (file)
index 0000000..4f0693a
Binary files /dev/null and b/res/images/large_profile_pic_border_bottom_left.png differ
diff --git a/res/images/large_profile_pic_border_bottom_right.png b/res/images/large_profile_pic_border_bottom_right.png
new file mode 100644 (file)
index 0000000..7e251d7
Binary files /dev/null and b/res/images/large_profile_pic_border_bottom_right.png differ
diff --git a/res/images/large_profile_pic_border_left.png b/res/images/large_profile_pic_border_left.png
new file mode 100755 (executable)
index 0000000..8931920
Binary files /dev/null and b/res/images/large_profile_pic_border_left.png differ
diff --git a/res/images/large_profile_pic_border_middle.png b/res/images/large_profile_pic_border_middle.png
new file mode 100755 (executable)
index 0000000..c26cb8d
Binary files /dev/null and b/res/images/large_profile_pic_border_middle.png differ
diff --git a/res/images/large_profile_pic_border_right.png b/res/images/large_profile_pic_border_right.png
new file mode 100755 (executable)
index 0000000..103c918
Binary files /dev/null and b/res/images/large_profile_pic_border_right.png differ
diff --git a/res/images/large_profile_pic_border_side_filler.png b/res/images/large_profile_pic_border_side_filler.png
new file mode 100644 (file)
index 0000000..3c45627
Binary files /dev/null and b/res/images/large_profile_pic_border_side_filler.png differ
diff --git a/res/images/large_profile_pic_border_top_filler.png b/res/images/large_profile_pic_border_top_filler.png
new file mode 100644 (file)
index 0000000..e533baa
Binary files /dev/null and b/res/images/large_profile_pic_border_top_filler.png differ
diff --git a/res/images/large_profile_pic_border_top_left.png b/res/images/large_profile_pic_border_top_left.png
new file mode 100644 (file)
index 0000000..cd9a00f
Binary files /dev/null and b/res/images/large_profile_pic_border_top_left.png differ
diff --git a/res/images/large_profile_pic_border_top_right.png b/res/images/large_profile_pic_border_top_right.png
new file mode 100644 (file)
index 0000000..d2a1ab6
Binary files /dev/null and b/res/images/large_profile_pic_border_top_right.png differ
index b047fd0..ddfdd46 100644 (file)
@@ -35,7 +35,7 @@ const QString TEST_API_KEY = "cf77865a5070f2c2ba3b52cbf3371579";
 // Situare PHP scripts
 const QString UPDATE_LOCATION = "updateLocation.php";
 const QString REVERSE_GEO = "reversegeo.php";
-const QString GET_LOCATIONS = "getLocations.php?extra_user_data=pic_big";
+const QString GET_LOCATIONS = "getLocations.php?extra_user_data=pic"; //pic_big
 
 // Cookies
 const QString COOKIE = "Cookie";
index afdc7c9..043fc93 100644 (file)
@@ -328,7 +328,7 @@ void SituareService::parseUserData(const QByteArray &jsonReply)
 
     QUrl imageUrl = userMap["profile_pic"].toUrl();
     qWarning() << "JOOO1" << imageUrl;
-    QUrl imageUrlBig = userMap["pic_big"].toUrl();
+    QUrl imageUrlBig = userMap["pic"].toUrl();
     qWarning() << "JOOO2" << imageUrlBig;
 
     if(imageUrl.isEmpty()) {
@@ -348,7 +348,7 @@ void SituareService::parseUserData(const QByteArray &jsonReply)
       QPointF coordinates(friendMap["longitude"].toReal(), friendMap["latitude"].toReal());
 
       QUrl imageUrl = friendMap["profile_pic"].toUrl();
-      QUrl imageUrlBig = friendMap["pic_big"].toUrl();
+      QUrl imageUrlBig = friendMap["pic"].toUrl();
 
       if(imageUrl.isEmpty()) {
           // friend doesn't have profile image, so we need to get him a silhouette image
index 74ccb89..9778e0d 100644 (file)
@@ -33,57 +33,111 @@ const int ROUNDNESS = 9;        ///< Image roundness
 const int CLIP_X_OFFSET = 1;    ///< Clip
 
 
-const int IMAGE_BORDER = 8;
+const int IMAGE_BORDER = 0;
+const int SMALL_IMAGE_SIZE = 50;
+const int IMAGE_MAX_HEIGHT = 200;
+const int LEFT_BORDER_WIDTH = 20;
+const int RIGHT_BORDER_WIDHT = 20;
+const int BORDER_HEIGHT = 118;
+const int MAX_IMAGE_WIDTH = 200;
+const int OFFSET = 9;
 
 QPixmap AvatarImage::create(const QPixmap &image)
 {
-//    QPixmap avatarImage = QPixmap(IMAGE_WIDTH, IMAGE_HEIGHT);
-//    avatarImage.fill(Qt::transparent);
-//    QPainter painter(&avatarImage);
-//
-//    QRect imageRect = QRect(0, 0, image.width(), image.height());
-//
-//    QPainterPath roundedRect;
-//    roundedRect.addRoundedRect(ORIGINAL_IMAGE_X-1, ORIGINAL_IMAGE_Y-1, imageRect.width()+1,
-//                               imageRect.height()+1,ROUNDNESS,ROUNDNESS);
-//    painter.save();
-//    painter.setClipPath(roundedRect);
-//    painter.drawPixmap(QPointF(ORIGINAL_IMAGE_X, ORIGINAL_IMAGE_Y), image);
-//    painter.restore();
-//    painter.drawPixmap(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
-//                       QPixmap(":/res/images/profile_pic_border.png"));
-//
-//    return avatarImage;
-
-
-
-    //addroundedRect taitaa olla aika turhaa koodia
-
-    //QPen pen(Qt::SolidLine, 5, Qt::green, Qt::RoundCap, Qt::RoundJoin);  // creates a default pen
-QPen pen;
-    //pen.setStyle(Qt::SolidLine);
-pen.setWidth(5);
-   pen.setBrush(Qt::green);
-//    pen.setCapStyle(Qt::RoundCap);
-//    pen.setJoinStyle(Qt::RoundJoin);
-
-    QPixmap avatarImage = QPixmap(image.width()+IMAGE_BORDER*2, image.height()+IMAGE_BORDER*2);
-    //avatarImage.fill(Qt::transparent);
-    //avatarImage.fill(Qt::blue);
+    qWarning() << __PRETTY_FUNCTION__;
+
+    if (image.height() == SMALL_IMAGE_SIZE && image.width() == SMALL_IMAGE_SIZE)
+    {
+        QPixmap avatarImage = QPixmap(IMAGE_WIDTH, IMAGE_HEIGHT);
+        avatarImage.fill(Qt::transparent);
+        QPainter painter(&avatarImage);
+
+        QRect imageRect = QRect(0, 0, image.width(), image.height());
+
+        QPainterPath roundedRect;
+        roundedRect.addRoundedRect(ORIGINAL_IMAGE_X-1, ORIGINAL_IMAGE_Y-1, imageRect.width()+1,
+                                   imageRect.height()+1,ROUNDNESS,ROUNDNESS);
+        painter.save();
+        painter.setClipPath(roundedRect);
+        painter.drawPixmap(QPointF(ORIGINAL_IMAGE_X, ORIGINAL_IMAGE_Y), image);
+        painter.restore();
+        painter.drawPixmap(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
+                           QPixmap(":/res/images/profile_pic_border.png"));
+
+        return avatarImage;
+    } else {
+
+    qWarning() << "AVATARIMAGE: alkup koko " << image.width() << image.height();
+
+    int imageHeight = image.height();
+    if (imageHeight > IMAGE_MAX_HEIGHT)
+        imageHeight = IMAGE_MAX_HEIGHT;
+
+    int imageWidth = image.width();
+    if (imageWidth < LEFT_BORDER_WIDTH + RIGHT_BORDER_WIDHT)
+        imageWidth = LEFT_BORDER_WIDTH + RIGHT_BORDER_WIDHT;
+    if (imageWidth > MAX_IMAGE_WIDTH)
+        imageWidth = MAX_IMAGE_WIDTH;
+
+    qWarning() << "AVATARIMAGE: uusi koko " << image.width() << image.height();
+    QPixmap avatarImage = QPixmap(imageWidth, imageHeight);
+    avatarImage.fill(Qt::transparent);
     QPainter painter(&avatarImage);
-    painter.setPen(pen);
-    //painter.drawPixmap(QPointF(10, 10),image);
-    QPixmap ownLocationIcon(":/res/images/led_red.png");
-    painter.drawPixmap(QPointF(image.width()-20, image.height()-30), ownLocationIcon);
-    //painter.eraseRect(QRect(QPoint(0,0),QPoint(100,100)));
-    //painter.setWindow(QRect(0, 0, avatarImage.width()/2, avatarImage.height()/2)); ei vaikuta
-    //painter.setViewport(QRect(0, 0, avatarImage.width()/2, avatarImage.height()/2)); ei vaikuta
-    painter.drawRect(QRect(0,0,image.width()+IMAGE_BORDER, image.height()+IMAGE_BORDER));
-    //painter.drawRoundedRect(QRect(0,0,image.width()+IMAGE_BORDER, image.height()+IMAGE_BORDER),IMAGE_BORDER, IMAGE_BORDER,Qt::AbsoluteSize);
-    //painter.drawRoundedRect(QRect(0,0,image.width()+IMAGE_BORDER, image.width()+IMAGE_BORDER),5,5,Qt::AbsoluteSize);
+    painter.drawPixmap(QPointF(OFFSET, OFFSET),image);
 
+    QRect left(0,0, LEFT_BORDER_WIDTH, imageHeight);
+    QRect middle(LEFT_BORDER_WIDTH, 0, image.width() - LEFT_BORDER_WIDTH - RIGHT_BORDER_WIDHT,
+        imageHeight);
+    QRect right(LEFT_BORDER_WIDTH + middle.width(), 0, RIGHT_BORDER_WIDHT, imageHeight);
 
+    QPixmap leftBorder(":/res/images/large_profile_pic_border_left.png");
+    QPixmap middleBorder(":/res/images/large_profile_pic_border_middle.png");
+    QPixmap rightBorder(":/res/images/large_profile_pic_border_right.png");
+
+    QPixmap topLeft(":/res/images/large_profile_pic_border_top_left.png");
+    QPixmap topRight(":/res/images/large_profile_pic_border_top_right.png");
+    QPixmap bottomLeft(":/res/images/large_profile_pic_border_bottom_left.png");
+    QPixmap bottomRight(":/res/images/large_profile_pic_border_bottom_right.png");
+
+    painter.drawPixmap(QPointF(0,0), topLeft);
+    painter.drawPixmap(QPointF(10,10), topRight);
+    painter.drawPixmap(QPointF(10,20), bottomLeft);
+    painter.drawPixmap(QPointF(10,30), bottomRight);
+
+
+//    painter.drawPixmap(left, leftBorder);
+//    painter.drawPixmap(middle, middleBorder);
+//    painter.drawPixmap(right, rightBorder);
 
 
     return avatarImage;
+    }
 }
+
+
+
+////       double scaleFactor = IMAGE_MAX_HEIGHT / image.height();
+////       painter.scale(scaleFactor, scaleFactor);
+//       //painter.translate(image.width()/2, image.height()/2);
+
+
+
+
+//       QPainterPath roundedRect;
+//       roundedRect.addRoundedRect(QRect(0, 0, image.width(),
+//                                  imageHeight), ROUNDNESS, ROUNDNESS, Qt::AbsoluteSize);
+//       painter.setClipPath(roundedRect); //pyöristys laittaa reunat valkoisiksi
+//       painter.drawPixmap(QPointF(IMAGE_BORDER, IMAGE_BORDER),image);
+
+       //painter.drawTiledPixmap();
+
+       //PYÖRISTÄ KUVAA
+//       QRect imageRect = QRect(0, 0, image.width(), image.height());
+//       QPainterPath roundedRect;
+//       roundedRect.addRoundedRect(ORIGINAL_IMAGE_X-1, ORIGINAL_IMAGE_Y-1, imageRect.width()+1,
+//                                  imageRect.height()+1,ROUNDNESS,ROUNDNESS);
+//       painter.setClipPath(roundedRect);
+
+       // PIIRRÄ KEHYS
+//       painter.drawPixmap(0, 0, image.width(), image.height(),
+//                          QPixmap(":/res/images/profile_pic_border.png"));