PIXNET Logo登入

Y CP的部落格

跳到主文

歡迎光臨Y CP在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 2月 21 週日 201023:58
  • memcpy動態陣列

memcpy
 作用: Copy block of memory
 用法:memcpy(指向destination的指標, 指向source的指標, 要copy幾個byte)
 see here
new
 作用:C++動態配置記憶體
 介紹:依所指定之型別與陣列大小配置一塊等大的記憶體
    可以為其設定初值
    return 該塊記憶體的起始位址
    通常需要一指標來接收回傳值,以存取所配置的記憶體空間
 格式:
  變數型別* 指標 = new 變數型別;  //不指定初值
  變數型別* 指標 = new 變數型別(初始值);  //指定初值
 
  變數型別 *指標名 = new 變數型別[陣列長度];  //一維陣列
  //多維陣列
  變數型別 (*指標名)[陣列長度2] = new 變數型別[陣列長度1] [陣列長度2];
  變數型別 (*指標名)[陣列長度2] [陣列長度3]= new 變數型別[陣列長度1][陣列長度2] [陣列長度3];
  ex: int *p3 = new int[10];
    double (*p4)[4] = new double[3][4];
    double (*p5)[4][5] = new double[3][4][5];
 
因為memcpy只能複製連續記憶體,所以要自製具有連續記憶體的動態陣列 see here
template < typename T >
T **Allocate2DArray( int nRows, int nCols){
    T **pp;
    T *p;
    T *curPtr;
    //(step 1) 宣告一個指標陣列的空間,內容指向元素陣列 each row 的開頭。pp指向指標陣列的起始位置。
    pp = new T*[nRows];
    //(step 2) 宣告一個元素陣列的空間。p指向元素陣列起始位置。
    p = new T [nRows * nCols];
    //(step 3) 將指標陣列裡的指標,指向元素陣列的正確位置。
    curPtr = p;
    for( int i = 0; i < nRows; i++){
        *(pp + i) = curPtr;
         curPtr += nCols;
    }
    return pp;
}
template < typename T >
void Free2DArray(T** Array){
    delete [] *Array;
    delete [] Array;
}
 
使用
 型態  **變數名稱 = Allocate2DArray<型態> ( 行數, 列數 )
  例:double **A = Allocate2DArray<double> ( 5, 7 );   //宣告5列7行的 double 二維陣列
 Free2DArray ( 變數名稱 ) 
  例:Free2DArray(A);
 可以像一般陣列一樣assign值
  例:A[2][5] = 0.5
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(2,551)

  • 個人分類:電腦和網際網路
▲top
  • 2月 11 週四 201014:49
  • function template

Function template  為「通用函式」(Generic function),和一般 function 不同的地方在於,可以為不同type的資料做相同的動作。也就是,將type給參數化,等到呼叫時才決定給的是什麼type。
定義Template
 template <typename T>  
 T GetMin (T a, U b) { 
      return (a<b?  a : b);
 }
 //或者寫成template <class T> T是自己取的參數名稱
 //可傳入兩個不同type的參數,在這個例子裡,這兩種是可以比大小的
使用
 遇到的問題
 function template 只拿回傳 type 當參數時,要明確指定它的 type
 template <class T> T** G(int M, int N) {
     T **ppi;
     /*      */
     return ppi;
 }
 int main(int argc, char *argv[]){
     double **d = G<double>(5,3); <=明確指定double
 }
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(26)

  • 個人分類:電腦和網際網路
▲top
  • 2月 10 週三 201023:22
  • 影像細部修補美化

髮絲,髒汙:汙點修復筆刷(適用於單調的背景)
細部修補: 修復筆刷工具 (先用Alt 鍵選參考點)
瞳孔:   紅眼工具
眼白,顴骨:加亮工具
唇色:   海綿工具(加強飽和度,使其亮眼)
眼袋,皮膚:仿製印章工具 (先用Alt 鍵選參考點)
眉毛:   加深工具
小臉,瘦身:濾鏡 => 液化 =>縮攏工具 (筆刷涵蓋範圍回朝中心點縮攏)
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(11)

  • 個人分類:photoshop
▲top
  • 2月 10 週三 201016:40
  • 相片變彩色鉛筆速寫

完全 copy 自 這裡





























Step 1.



  • 開啟檔案:『檔案/開啟舊檔』或 Ctrl + O


Step 2.



  • 去除飽和度,按『影像/調整/去除飽和度』或 Shift + Ctrl + U。
  • 再複製一個圖層,『圖層/新增/拷貝的圖層』或 Ctrl + J。


Step 3.



  • 將新增的圖層1變為負片效果,按『影像/調整/負片效果』或 Ctrl + I。


Step 4.



  • 在圖層浮動視窗中將正常模式改為 加亮顏色 。
    註:此時相片完全變白。


Step 5.



  • 按『濾鏡/模糊/高斯模糊』,調整強度。(數值依實際情況設定)


Step 6.



  • 利用 步驟記錄筆刷工具 ,在選項列將不透明降至 20% 。選用大型的筆刷(200以上)。
  • 按住滑鼠再圖片上畫一遍。
  • 按鍵盤上的 [ 讓筆刷變小,針對雙頰、眼珠再點幾次,可回復更多色彩。


Step 7.



  • 將2個圖層合併,按『圖層/合併可見圖層』或 Ctrl + E。
  • 設定紋理,按『濾鏡/紋理/紋理化』,數值參考右圖。


Step 8.



  • 套用濾鏡後,可在按『編輯/淡化 紋理化』,將不透明度降低,減少紋理效果的強度。



成品


(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(75)

  • 個人分類:photoshop
▲top
  • 2月 07 週日 201023:19
  • Ancient Egypt's Royal Makeup: Toxic, Yet Healing

The New York Times 
January 19, 2010
The elaborate eye makeup worn by Queen Nefertiti and other ancient Egyptians was believed to have healing powers, conjuring up the protection of the Gods Horus and Ra and warding off illnesses.
Science does not allow for magic, but it does allow for healing cosmetics. The lead-based makeup used by the Egyptians had antibacterial properties that helped prevent infections common at the time, according to a report published in Analytical Chemistry, a semimonthly journal of the American Chemical Society.
"It was puzzling; they were able to build a strong, rich society, so they were not completely crazy," said Christian Amatore, a chemist at the Ecole Normale Superieure in Paris and one of the paper's authors. "But they believed this makeup was healing -- they said incantations as they mixed it, things that today we call garbage."
Amatore and his fellow researchers used electron microscopy and X-ray diffraction to analyze 52 samples from containers of Egyptian makeup preserved at the Louvre. They found that the makeup was primarily made by mixing four lead-based chemicals: galena, which produced dark tones and gloss, and the white materials cerussite, laurionite and phosgenite.
Because the samples had disintegrated over the centuries, the researchers were not able to determine what percentage of the makeup was lead.
Although many written texts, paintings and statues from the period indicate that the makeup was extensively used, Egyptians saw it as magical, not medicine, Amatore said.
In ancient Egypt, during periods when the Nile flooded, Egyptians had infections caused by particles that entered the eye and caused diseases and inflammations. The scientists argue that the lead-based makeup acted as a toxin, killing bacteria before it spread.
But while their research provides a fascinating insight into an ancient culture, the scientists say the makeup is not something that should be used today.
Amatore said that the toxicity of lead compounds overshadowed the benefits and that there had been many documented cases of poisoning as a result of lead in paints and plumbing in the 20th century.
Neal Langerman, a physical chemist and the president of Advanced Chemical Safety, a health safety and environmental protection consulting firm, said, "You probably won't want to do this at home, especially if you have a small child or a dog that likes to lick you."
Nonetheless, Langerman said, it makes sense that the Egyptians were attracted to the compounds.
"Lead and arsenic, among other metals, make beautiful color pigments," he said. "Because they make an attractive color and because you can create a powder with them, it makes sense to use it as a skin colorant."
The issue of lead in makeup continues to be debated in the cosmetics industry, particularly with regard to the small amounts of lead found in some lipsticks.
While some advocacy groups and doctors argue that, over time, lipstick wearers might absorb levels of lead that could result in behavioral issues, the Food and Drug Administration has said that the trace amounts of lead in makeup are too small to cause harm.
"It's the dose that makes the poison," Langerman said, in paraphrasing the Renaissance physician Paracelsus. "A low dose kills the bacteria. In a high dose, you're taking in too much."
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(3)

  • 個人分類:
▲top
  • 2月 06 週六 201021:28
  • 農曆12月24日

農曆12月24日子時送神
 「送神早、接神晚」,一般送神都在子時。
今日(23日,阿嬤睡覺以前) 準備:
 金紙二只
 雲馬總馬:恭送諸神騎馬返 回天庭
 橘子六顆:伴手禮
 
農曆正月初四接神 
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(300)

  • 個人分類:
▲top
  • 2月 03 週三 201019:40
  • 聖誕紅

節錄自  here  here
 
介紹
我們在欣賞聖誕紅的時候,常常會將苞葉認為是花的部分。
事實上,聖誕紅真正的花朵是著生在苞葉中央部份那幾顆如豆粒大小壺狀的小花。
就植物學上來說,聖誕紅的「花」就是由這些豆粒般的小花所集合而成的。
每一朵小花是由一枚雌蕊和數枚雄蕊所構成的,小花旁邊附有一個黃色的袋狀物,
這是「蜜槽」,內有蜜腺,到了開花期就會溢出蜜汁。
 
開花習性
聖誕紅是屬於短日照的植物,只要將陽光照射的時間縮短,花芽就會開始分化,苞葉也開始轉紅。
在自然的情況下,每年十月以後,日照變短,這是自然界促進花芽分化的主要功用;
如果聖誕紅在這時候受到路燈、庭園燈或是室內燈光等人工日照影響,延長了接受日照的時間,花芽便無法分化,那麼苞葉也就不會變紅了。
 
照顧
 1.將聖誕紅擺在至少有6小時半日照處,避免陽光直射處。
 2.理想室溫為18℃至25℃。
 3.盆內介質乾後再澆水。
 4.避免將植物擺在高溫處。
 5.避免將植物置於15℃以下環境。
 6.避免澆水過量,或其底盤經常積水,澆水後應讓它完全排水後再擺回原底盤內。
 7.運送植物時,避免招受寒風吹,及過度搖晃植株。
 8.由於聖誕紅的觀賞期長,買回家後可以施一些好康多一號14-12-14於盆面,維持花期所需養分;
 花期結束後,若希望栽培至明年,建議每三個月施用一次好康多一號,並以花寶二號當追肥,補充所需的養分。
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(29)

  • 個人分類:植物
▲top
  • 2月 03 週三 201014:35
  • 黃金葛

節錄自 here
 
黃金葛蛇木棍環繞盆栽。
種植時在盆中央可豎立一根蛇木棍,在四周種小苗3—5株,使枝蔓攀附於支柱上生長﹔
在枝蔓生長過程中應經常噴水保濕,以促使莖節上發生不定根,並附於柱上。
注意莖蔓攀爬狀況並適度調整,使葉片大小均勻,可使株形成長完美。
 
黃金葛吊掛或懸垂栽培。
也可將小苗3—5株直接種在盆中,使莖蔓下垂。
小苗期不可多澆水,以免根頸處發生腐爛﹔生長旺期要充分澆水或噴霧。
為保持良好的株形,要修剪過長的莖蔓和紊亂的枝條。
 
施肥
    黃金葛在生長過程中需肥量較大,若營養不足葉片不易長大。
    生長期(3~8 月)應每週施肥,要常以濕布清潔葉面。
    一般每兩周左右施一次液肥。施肥時不要偏施氮肥,否則葉面上斑點、斑塊容易變綠,會降低觀賞價值。
日照
    除夏天陽光過強應遮陰外,其餘時期應盡可能讓其多接受陽光,使其節問充實、葉色濃綠。
    若光線過弱,葉面的斑紋也容易變少或消失,影響觀賞效果。
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(795)

  • 個人分類:植物
▲top
  • 2月 01 週一 201014:03
  • 專案設定(using Matlab)

新增環境變數
=>使用者變數 
名稱MATLAB , 路徑C:\Program Files\MATLAB71
 
專案
專案=>屬性=>組態屬性=>C/C++ =>一般=>include C:\Program Files\MATLAB71\extern\include;C:\Program Files\MATLAB71\simulink\include
專案=>屬性=>組態屬性=>連結器=>命令列=>其他選項 libeng.lib libmat.lib libmx.lib libmex.lib
工具=>選項=>VC++目錄=>程式庫檔  $(MATLAB)\extern\lib,   $(MATLAB)\extern\lib\win32\microsoft
 
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(559)

  • 個人分類:電腦和網際網路
▲top
  • 1月 29 週五 201012:58
  • 連續讀檔

#include <windows.h> 
#include <tchar.h>   
 
int main(int argc, char *argv[]){
    WIN32_FIND_DATA FileData;
    BOOL fFinished;
    HANDLE hList;
    FILE *stream;
   
    hList = FindFirstFile("*", &FileData);
    if (hList == INVALID_HANDLE_VALUE){
        printf("No files under this direction");
    }
    else{
              fFinished = FALSE;
               while (!fFinished){
                         if ( strstr(FileData.cFileName,".txt") ){ //判斷副檔名是不是 .txt  
                                  stream = fopen(FileData.cFileName,"r"); //fopen( const char * filename, const char * mode );
                                  if(stream==NULL){
                                            //return;
                                  }
                                  else{ //讀檔                    
                                  }
                                  fclose(stream); 
                           }//if 判斷副檔名是不是 .txt
                          //--------------計算-------------//
                           if (!FindNextFile(hList, &FileData)){
                                   if (GetLastError() == ERROR_NO_MORE_FILES){
                                           fFinished = TRUE;
                                   }
                            }
                 }//while
    }
    FindClose(hList);
    system("PAUSE");
    return EXIT_SUCCESS;
}
 
(繼續閱讀...)
文章標籤

Y CP 發表在 痞客邦 留言(0) 人氣(378)

  • 個人分類:電腦和網際網路
▲top
«123...9»

自訂側欄

自訂側欄

個人資訊

Y CP
暱稱:
Y CP
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (10,551)C關鍵字 volatile, restrict
  • (3,053)函數呼叫
  • (2,551)memcpy動態陣列
  • (378)連續讀檔
  • (291)煙火花
  • (96)如此濃烈的「色」,如此肅殺的「戒」 - 龍應台
  • (41)令人高興的心理測驗
  • (11)影像細部修補美化
  • (7)老王

文章分類

  • 娛樂 (2)
  • 植物 (3)
  • photoshop (4)
  • 自然科學 (1)
  • 電腦和網際網路 (12)
  • 未分類文章 (1)

最新文章

  • 圖片格式 gif, jpg, png
  • C關鍵字 volatile, restrict
  • 夕陽的顏色
  • 自動裁剪 掃描相片
  • 快樂數
  • 函數呼叫
  • C vs C++
  • Pointer to function
  • 陣列的參數傳遞
  • photoshop 工作環境

最新留言

  • [24/03/30] 新飛Hsinfei 於文章「主題論述:為甚麼我們應該把我們的病歷中文...」留言:
    醫護英文對話10句分享,不需靠醫護英文翻譯軟體也能溝通! h...
  • [19/11/15] 廣利 於文章「難過..是一種病...」留言:
    超級生命密碼-泯恩仇,導師演唱版 連結網址: https...
  • [15/01/23] miller 於文章「主題論述:為甚麼我們應該把我們的病歷中文...」留言:
    邏輯錯亂。我只提出幾點: >難道大家這麼多的病歷每份真...
  • [09/09/16] Cindy 於文章「開學...」留言:
    真的!!!!!!! 在北京生活的這麼幾個月 我深深的認知一件...
  • [08/10/21] ... 於文章「林呆呆要見丈人&丈母娘...」留言:
    Go Go Go A Le A Le A Le!!! ...
  • [08/10/19] takeeasy 於文章「林呆呆要見丈人&丈母娘...」留言:
    囧囧囧 ...
  • [07/09/13] 政維 於文章「winter in July...」留言:
    寫的真好  我喜歡 ...
  • [07/09/12] CP 於文章「winter in July...」留言:
      Future dreams can never las...
  • [07/08/31] frank 於文章「新的耳環!...」留言:
    正喔~  ...
  • [07/08/30] CP 於文章「none...」留言:
    小雞真貼心  親一個   ~~*  ...

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: