diff options
-rwxr-xr-x | indra/llimage/llimage.cpp | 20 | ||||
-rwxr-xr-x | indra/llimage/llimage.h | 3 | ||||
-rw-r--r-- | indra/newview/llfloaterflickr.cpp | 32 | ||||
-rw-r--r-- | indra/newview/llfloaterflickr.h | 1 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.cpp | 16 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.h | 3 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_flickr_photo.xml | 31 |
7 files changed, 73 insertions, 33 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index c8a05e1fae..e5281feff0 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -933,6 +933,26 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) return TRUE ; } +// *TODO : Implement real color transform +// Merov : This is temporary code for testing... +void LLImageRaw::colorTransform() +{ + const S32 components = getComponents(); + llassert( components >= 1 && components <= 4 ); + + S32 pixels = getWidth() * getHeight(); + U8* dst_data = getData(); + llinfos << "Merov : Convert the image to Black and White!!! pixels = " << pixels << ", comp = " << components << llendl; + for( S32 i=0; i<pixels; i++ ) + { + U8 gray = (U8)(((U32)(dst_data[0]) + (U32)(dst_data[1]) + (U32)(dst_data[2]))/3); + dst_data[0] = gray; + dst_data[1] = gray; + dst_data[2] = gray; + dst_data += components; + } +} + void LLImageRaw::copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len, S32 in_pixel_step, S32 out_pixel_step ) { const S32 components = getComponents(); diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 2277afc585..96c37f5436 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -255,6 +255,9 @@ public: // Src and dst are same size. Src has 4 components. Dst has 3 components. void compositeUnscaled4onto3( LLImageRaw* src ); + + // Filter operations + void colorTransform(); protected: // Create an image from a local file (generally used in tools) diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp index 0a4c3f091b..675266143d 100644 --- a/indra/newview/llfloaterflickr.cpp +++ b/indra/newview/llfloaterflickr.cpp @@ -92,6 +92,8 @@ BOOL LLFlickrPhotoPanel::postBuild() mSnapshotPanel = getChild<LLUICtrl>("snapshot_panel"); mResolutionComboBox = getChild<LLUICtrl>("resolution_combobox"); mResolutionComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE)); + mFilterComboBox = getChild<LLUICtrl>("filters_combobox"); + mFilterComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE)); mRefreshBtn = getChild<LLUICtrl>("new_snapshot_btn"); mWorkingLabel = getChild<LLUICtrl>("working_lbl"); mThumbnailPlaceholder = getChild<LLUICtrl>("thumbnail_placeholder"); @@ -301,33 +303,18 @@ void LLFlickrPhotoPanel::clearAndClose() void LLFlickrPhotoPanel::updateControls() { LLSnapshotLivePreview* previewp = getPreviewView(); - BOOL got_bytes = previewp && previewp->getDataSize() > 0; BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - LLSnapshotLivePreview::ESnapshotType shot_type = (previewp ? previewp->getSnapshotType() : LLSnapshotLivePreview::SNAPSHOT_POSTCARD); // *TODO: Separate maximum size for Web images from postcards lldebugs << "Is snapshot up-to-date? " << got_snap << llendl; - LLLocale locale(LLLocale::USER_LOCALE); - std::string bytes_string; - if (got_snap) - { - LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); - } - - //getChild<LLUICtrl>("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : getString("unknown")); <---uses localized string - getChild<LLUICtrl>("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : "unknown"); - getChild<LLUICtrl>("file_size_label")->setColor( - shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD - && got_bytes - && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" )); - updateResolution(FALSE); } void LLFlickrPhotoPanel::updateResolution(BOOL do_update) { - LLComboBox* combobox = static_cast<LLComboBox *>(mResolutionComboBox); + LLComboBox* combobox = static_cast<LLComboBox *>(mResolutionComboBox); + LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox); std::string sdstring = combobox->getSelectedValue(); LLSD sdres; @@ -336,6 +323,9 @@ void LLFlickrPhotoPanel::updateResolution(BOOL do_update) S32 width = sdres[0]; S32 height = sdres[1]; + + const std::string& filter_name = filterbox->getSimple(); + llinfos << "Merov : filter name is : " << filter_name << llendl; LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get()); if (previewp && combobox->getCurrentIndex() >= 0) @@ -359,10 +349,16 @@ void LLFlickrPhotoPanel::updateResolution(BOOL do_update) checkAspectRatio(width); previewp->getSize(width, height); + // Merov : + // Get the old filter, compare to the current one "filter_name" and set if changed + // If changed, also force the updateSnapshot() here under + S32 original_filter = previewp->getFilter(); + S32 filter = ("Gray Scale" == filter_name ? 1 : 0); - if(original_width != width || original_height != height) + if ((original_width != width) || (original_height != height) || (original_filter != filter)) { previewp->setSize(width, height); + previewp->setFilter(filter); // hide old preview as the aspect ratio could be wrong lldebugs << "updating thumbnail" << llendl; diff --git a/indra/newview/llfloaterflickr.h b/indra/newview/llfloaterflickr.h index 9a329d4451..1d9e649899 100644 --- a/indra/newview/llfloaterflickr.h +++ b/indra/newview/llfloaterflickr.h @@ -63,6 +63,7 @@ private: LLUICtrl * mSnapshotPanel; LLUICtrl * mResolutionComboBox; + LLUICtrl * mFilterComboBox; LLUICtrl * mRefreshBtn; LLUICtrl * mWorkingLabel; LLUICtrl * mThumbnailPlaceholder; diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 7f578975db..ab9788a88b 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -89,7 +89,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param mCameraPos(LLViewerCamera::getInstance()->getOrigin()), mCameraRot(LLViewerCamera::getInstance()->getQuaternion()), mSnapshotActive(FALSE), - mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR) + mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR), + mFilterType(0) { setSnapshotQuality(gSavedSettings.getS32("SnapshotQuality")); mSnapshotDelayTimer.setTimerExpirySec(0.0f); @@ -585,7 +586,12 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) if(raw) { raw->expandToPowerOfTwo(); - mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); + // Merov : Filter also the thumbnail? + if (getFilter() == 1) + { + raw->colorTransform(); + } + mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); mThumbnailUpToDate = TRUE ; } @@ -689,6 +695,12 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) } else { + // Merov : Time to apply the filter to mPreviewImage!!! + if (previewp->getFilter() == 1) + { + previewp->mPreviewImage->colorTransform(); + } + // delete any existing image previewp->mFormattedImage = NULL; // now create the new one of the appropriate format. diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h index 0c63bf47c7..d5ae3b491b 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -95,6 +95,8 @@ public: void setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat type) { mSnapshotFormat = type; } bool setSnapshotQuality(S32 quality, bool set_by_user = true); void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; } + void setFilter(S32 filter) { mFilterType = filter; } + S32 getFilter() { return mFilterType; } void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f); void saveWeb(); void saveTexture(); @@ -154,6 +156,7 @@ private: LLQuaternion mCameraRot; BOOL mSnapshotActive; LLViewerWindow::ESnapshotType mSnapshotBufferType; + S32 mFilterType; // *TODO: eventually use a string and a named filter public: static std::set<LLSnapshotLivePreview*> sList; diff --git a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml b/indra/newview/skins/default/xui/en/panel_flickr_photo.xml index b3af271f34..28e3557e15 100644 --- a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml +++ b/indra/newview/skins/default/xui/en/panel_flickr_photo.xml @@ -40,19 +40,24 @@ name="1024x768" value="[i1024,i768]" /> </combo_box> - <text - follows="left|top" - font="SansSerifSmall" - height="14" - left="208" - length="1" - halign="right" - name="file_size_label" - top="9" - type="string" - width="50"> - [SIZE] KB - </text> + <combo_box + control_name="SocialPhotoFilters" + follows="right|top" + name="filters_combobox" + tool_tip="Image filters" + top="6" + left="165" + height="21" + width="135"> + <combo_box.item + label="No Filter" + name="NoFilter" + value="NoFilter" /> + <combo_box.item + label="Gray Scale" + name="GrayScale" + value="GrayScale" /> + </combo_box> <panel height="150" width="250" |