मैं Grishu के डेमो परियोजना संशोधित कर लिया है: (तीन प्रभाव लागू किए गए छवि घुमाया, - फ्लिप क्षैतिज, crossprocess, फ़िशआई)
1): here's a Screen Recording, तो कुछ स्पष्टीकरण परिणाम पर प्रभाव लागू करने के लिए, आपका सुझाव ठीक काम करता है। मैं वास्तव में समझ नहीं पा रहा हूं कि आप क्या मतलब रखते हैं, प्रगति परिवर्तन प्रभाव ''। क्या आप प्रभाव के पैरामीटर ट्यून करना चाहते हैं?
2) संकेतों के लिए आपको GLSurfaceView
का विस्तार करना चाहिए और GestureDetector.OnGestureListener
और/या ScaleGestureDetector.OnScaleGestureListener
को अपनी आवश्यकताओं के आधार पर लागू करना चाहिए। TouchGLView यहाँ देखें: Source, या नीचे टुकड़ा:
private class TouchGLView extends GLSurfaceView
implements GestureDetector.OnGestureListener,
ScaleGestureDetector.OnScaleGestureListener {
private TextureRenderer mRenderer;
private GestureDetector mTapDetector;
private ScaleGestureDetector mScaleDetector;
private float mLastSpan = 0;
TouchGLView(Context c) {
super(c);
// Use Android's built-in gesture detectors to detect
// which touch event the user is doing.
mTapDetector = new GestureDetector(c, this);
mTapDetector.setIsLongpressEnabled(false);
mScaleDetector = new ScaleGestureDetector(c, this);
// Create an OpenGL ES 2.0 context.
setEGLContextClientVersion(2);
mRenderer = new TextureRenderer(c);
setRenderer(mRenderer);
}
@Override
public boolean onTouchEvent(final MotionEvent e) {
// Forward touch events to the gesture detectors.
mScaleDetector.onTouchEvent(e);
mTapDetector.onTouchEvent(e);
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
final float dx, final float dy) {
// Forward the drag event to the renderer.
queueEvent(new Runnable() {
public void run() {
mRenderer.drag(dx, dy);
}});
return true;
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
// Forward the scale event to the renderer.
final float amount = detector.getCurrentSpan() - mLastSpan;
queueEvent(new Runnable() {
public void run() {
mRenderer.zoom(amount);
}});
mLastSpan = detector.getCurrentSpan();
return true;
}
...
}
3) आप शीर्ष को संशोधित करने का समन्वय करता है और खाते में व्यूपोर्ट लेने के द्वारा छवि घुमा सकते हैं। इसके अलावा, आप विभिन्न रोटेशन लागू कर सकते हैं। आप व्यू (वर्टेक्स निर्देशांक) को घुमाने (और ज़ूम) कर सकते हैं (जो मूल बनावट बफर को प्रभावित नहीं करता है) या आप बनावट पिक्सेल बनावट बना सकते हैं (जो 90 डिग्री, 180 डिग्री, आदि के लिए आसान है) और फिर नई छवि चौड़ाई/ऊंचाई से मेल खाने के लिए अपने चरम निर्देशांक अपडेट करें।
private void computeOutputVertices() {
if (mPosVertices != null) {
float imgAspectRatio = mTexWidth/(float)mTexHeight;
float viewAspectRatio = mViewWidth/(float)mViewHeight;
float x0, y0, x1, y1;
// Set initial vertex coords based in texture aspect
if (imgAspectRatio > 1.0f) {
x0 = -1.0f ;
y0 = -1.0f/imgAspectRatio;
x1 = 1.0f ;
y1 = 1.0f/imgAspectRatio;
} else {
x0 = -1.0f *imgAspectRatio;
y0 = -1.0f;
x1 = 1.0f *imgAspectRatio;
y1 = 1.0f;
}
float[] coords = new float[] { x0, y0, x1, y0, x0, y1, x1, y1 };
// Scale coordinates with mZoom
for (int i = 0; i < 8; i++) {
coords[i] *= mZoom;
}
// Rotate coordinates with mRot
float cosa = (float)Math.cos(mRot);
float sina = (float)Math.sin(mRot);
float x,y;
for (int i = 0; i < 8; i+=2) {
x = coords[i]; y = coords[i+1];
coords[i] = cosa*x-sina*y;
coords[i+1] = sina*x+cosa*y;
}
// Finally scale again to match screen aspect
if (viewAspectRatio > 1.0f) {
for (int i = 0; i < 8; i+=2) {
coords[i] = coords[i]/viewAspectRatio;
}
} else {
for (int i = 1; i < 8; i+=2) {
coords[i] = coords[i]*viewAspectRatio;
}
}
mPosVertices.put(coords).position(0);
}
}
मैं तुम्हें ओपन मैट्रिक्स में गोता लगाने और उन्हें प्रयोग इन सभी परिवर्तनों करने के लिए सुझाव देते हैं:
यहाँ शीर्ष coords के साथ जोड़ तोड़ के लिए एक उदाहरण है।
मैंने TextureRenderer
कक्षा को GLSurfaceView.Renderer
लागू करने के लिए संशोधित किया है, और रेंडरमोड को RENDERMODE_CONTINUOUSLY
में बदल दिया है।
अंत में, source for the modified demo is here।
उत्तर 1 के लिए सबसे पहले धन्यवाद 1) क्या खोजकर्ता की प्रगति में बदलाव लागू हो सकता है? क्योंकि यह पहली बार फ़ाइल काम करता है जब मैं "mTextures [0]" से "mTextures [1]" और rander textureId "mTextures [1]" से प्रभाव लागू करता हूं। प्रभाव लागू करने के बाद पहली बार लागू होने पर, दूसरे प्रभाव को लागू करने के लिए खोजकर्ता की प्रगति में "अनुबंध" कहें तो प्रभाव "mTextures [1]" से "mTextures [1]" पर लागू होता है और बनावट "mTextures [1]" प्रस्तुत करता है। आप देखेंगे कि छवि काली हो जाएगी। –
मुझे लगता है कि अगर मैं ताजा बनावट के रूप में "mTextures [1]" का पुन: उपयोग करता हूं। मेरी समस्या हल हो जाएगी, लेकिन यह नहीं पता कि इसका पुन: उपयोग कैसे करें। 2) ज़ूम करने के लिए पिंच करें: अच्छी तरह से काम करता है, लेकिन स्क्रॉलिंग छवि के साथ समस्या। कोई उपाय? 3) घूर्णन: अच्छी तरह से काम करता है। क्या घड़ी की दिशा में (90,180,270, ...) पर रोशन प्रभाव में निर्माण का उपयोग करके रोटेशन लागू करना संभव है। –
दोस्तों रोटेशन और ज़ूम अच्छी तरह से काम करता है लेकिन ड्रैग काम नहीं कर रहा है ... कैसे हल करें। –