2012-10-12 21 views
12

ज़िक्सिंग बारकैकर ऐप निचोड़ना, मैंने इसे लाइब्रेरी प्रोजेक्ट के रूप में कार्यान्वित किया है, और यह काम करता है।जेएक्सिंग्स बारकोड्सकेनर में मेनू जोड़ना, और सतहदृश्य

अब मैं फ़ील्ड (लक्ष्य फ़ील्ड) का आकार बदलना चाहता हूं जो स्कैन किया गया है (साथ ही किया गया)। (हालांकि स्कैनिंग क्षेत्र वही रहता है, इससे कोई फर्क नहीं पड़ता क्योंकि फोकस अभी भी केंद्र में था।)

लेकिन फिर मुझे बाईं ओर एक मेनू डालने की आवश्यकता थी। यह मुझे लक्ष्य फ़ील्ड को बदलने के लिए मजबूर करता है, और यह क्रैश हो रहा है, अगर मैं सतही दृश्य का आकार बदलता हूं या दृश्यदर्शी दृश्य देखता हूं और यदि मैं इसे सापेक्ष दृश्य में लपेटता हूं, तो यह अभी भी केंद्र (कारण) को डीकोड करता है। मैं बस एक समाधान नहीं समझ सकता: -/

लघु: मैं उस क्षेत्र को बदलने में सक्षम हूं जहां स्कैन होना चाहिए, लेकिन यह केवल दिखाई दे रहा है। वास्तविक स्कैन किए गए क्षेत्र अभी भी पूरी स्क्रीन का केंद्र है और स्थानांतरित दृश्यमान स्कैन क्षेत्र का केंद्र नहीं है।

क्या कोई मेरी मदद कर सकता है?

लेआउट एक्सएमएल (मेनू डाला, और अनावश्यक हटाया के साथ):

<SurfaceView 
    android:id="@+id/preview_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

<com.google.zxing.client.android.ViewfinderView 
    android:layout_marginLeft="120dip" 
    android:id="@+id/viewfinder_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/transparent" /> 

<LinearLayout 
    android:id="@+id/buttonPanel" 
    android:layout_width="120dip" 
    android:layout_height="fill_parent" 
    android:background="#000" 
    android:orientation="vertical" 
    android:paddingBottom="15dip" 
    android:paddingTop="15dip" > 

    <TextView 
     android:id="@+id/menuText" 
     android:layout_weight="1" 
     android:layout_width="90dip" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dip" 
     android:text="@string/menu_title"/> 
    <ImageView 
     android:id="@+id/d1Button" 
     android:layout_width="90dip" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dip" 
     android:layout_weight="2" 
     android:onClick="scanner1d" 
     android:src="@drawable/d1image" /> 

    <ImageView 
     android:id="@+id/d2Button" 
     android:layout_width="90dip" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dip" 
     android:layout_weight="2" 
     android:onClick="scanner2d" 
     android:src="@drawable/d2image" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/result_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/result_view" 
    android:orientation="vertical" 
    android:padding="4dip" 
    android:visibility="gone" > 

     **removed** 
</LinearLayout> 
    **removed** 

वाम चित्र: कैसे दृश्य है और आइटम रखा है, जहां यह मान्यता प्राप्त नहीं किया जा रहा है है ।

सही चित्र: रखा मद जहां यह मान्यता प्राप्त है (मैं कैसे कि लक्षित क्षेत्र की जाँच नहीं बदला गया है):

Image of view result found

CameraManager में किए गए परिवर्तन (दृश्यदर्शी का निचोड़):

public Rect getFramingRect() { 
    // added 
    int menuSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
        (float) 120, context.getResources().getDisplayMetrics()); 
    // end of added 

    Point screenResolution = configManager.getScreenResolution(); 
    if (framingRect == null) { 
     if (camera == null) { 
      return null; 
     } 
     int width = screenResolution.x * 3/4; 
     if (width < MIN_FRAME_WIDTH) { 
      width = MIN_FRAME_WIDTH; 
     } else if (width > MAX_FRAME_WIDTH) { 
      width = MAX_FRAME_WIDTH; 
     } 
     int height = screenResolution.y * 3/4; 
     if (height < MIN_FRAME_HEIGHT) { 
      height = MIN_FRAME_HEIGHT; 
     } else if (height > MAX_FRAME_HEIGHT) { 
      height = MAX_FRAME_HEIGHT; 
     } 


     // added menu size for calculation 

     int leftOffset = ((screenResolution.x -menuSize - width)/2); 
     int topOffset = (screenResolution.y - height)/2; 
     framingRect = new Rect(leftOffset, topOffset, leftOffset + width, 
       topOffset + height); 
     Log.d(TAG, "Calculated framing rect: " + framingRect); 
    } 
    return framingRect; 
} 

अब मैंने इसे एक छोटी परियोजना में ले लिया है जिसे here (समस्या ठीक हो गई है, एक lib लापता था) oct 18 10:14 सी ईटी

+0

इसके रास्ते पर कोड, –

+0

पर रोकें स्टैकट्रैक खोएं, उन्हें पुनर्निर्माण पर काम करेंगे। और जल्द ही उन्हें एक स्पष्टीकरण जोड़ें –

+0

दुर्घटना तब थी जब सतही दृश्य बड़ा था तो viewfinderview, लेकिन यदि समान आकार है, तो यह "काम करता है", फिर भी पहचानने के साथ बड़ी समस्या है। –

उत्तर

1

यदि आप viewfinderview के साथ दोनों सतहदृश्य को निचोड़ते हैं, तो यह वास्तव में काम करेगा।

हालांकि आपको यह ध्यान में रखना होगा कि छवि निचोड़ा हुआ है, इसलिए लक्ष्य आयताकार इतना छोटा होना चाहिए।