Zoom Camera2 Preview using TextureView

i have a Problem with my Preview Zoom for the Camera2 API. I am using a TextureView.

I want to zoom only the preview Stream that was showed in the TextureView.

I want to zoom the Area where i use the Zoom Gesture.

I use the SimpleOnScaleGestureListener!

I added following Code. The zoomingFactor and the x and y Position are right.

 private void updateTextureViewSize(float xPosi,float yPosi, float scale){
        float scaleX = 1.0f;
        float scaleY = 1.0f;




        float mVideoWidth = mCamcontrol.getmPreviewSize().getWidth();
        float mVideoHeight = mCamcontrol.getmPreviewSize().getHeight();

        int rotation = getWindowManager().getDefaultDisplay().getRotation();
        RectF viewRect = new RectF(0, 0, 1440, 2560);
        RectF bufferRect = new RectF(0, 0, mVideoHeight, mVideoWidth);

        bufferRect.offset(xPosi - bufferRect.centerX(), yPosi -    bufferRect.centerY());

         //16:9 faktor
        scaleX = ((mScale * scale) / 9f) * 16f;
        scaleY = ((mScale * scale) / 16f) * 9f;

        Matrix matrix = new Matrix();

        matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL);
        scalefactorView.setText(String.valueOf(xPosi) + "  " + String.valueOf(yPosi));

        matrix.setScale(scaleY, scaleX, xPosi, yPosi);
        matrix.postRotate(90 * (rotation - 2), xPosi, yPosi);

        mTextureView.setTransform(matrix);


}

read more

How to print byte array data to Zebra printer?

I want to print a PDF file to Zebra printer using a Java application. I have generated a PDF using Jasper reports with 2D bar codes. If I am performing manual print to Zebra printer it’s printing that PDF file but once I am trying to print the same pdf file using the Java application, the job is submitting to printer but print is not happening.

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.event.PrintJobAdapter;
import javax.print.event.PrintJobEvent;

public class ZebraPrintUtil {
    public static void main(String[] args) throws IOException, InterruptedException {
        byte[] content = convertFileToBytes("D://old files/test123.pdf");
        print(content, "ZDesigner GX420t");
    }

    private static byte[] convertFileToBytes(String absoluteFilePath) throws IOException {
        File file = new File(absoluteFilePath);
        FileInputStream fis = new FileInputStream(file);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] buf = new byte[1024];

        try {
            for (int readNum;
            (readNum = fis.read(buf)) != -1;) {
                bos.write(buf, 0, readNum); // no doubt here is 0
            }
        } catch (IOException ex) {

        } finally {
            if (fis != null) {
                fis.close();
            }
        }

        byte[] bytes = bos.toByteArray();
        return bytes;
    }

    private static boolean print(byte[] byteArray, String reqPrinterId)
            throws IOException, InterruptedException {
        boolean isPrintedSuccessfully = false;
        DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        PrintService[] services = PrintServiceLookup.lookupPrintServices(
        flavor, null);

        if (services.length > 0) {
            PrintService myService = null;

            for (PrintService service: services) {
                if (service.getName().contains(reqPrinterId)) {
                    myService = service;
                    break;
                }
            }

            DocPrintJob printJob = myService.createPrintJob();
            JobCompleteMonitor monitor = new JobCompleteMonitor();
            printJob.addPrintJobListener(monitor);
            Doc document = new SimpleDoc(byteArray, flavor, null);

            try {
                printJob.print(document, null);
                monitor.waitForJobCompletion();
                System.out.println("-------------------- Print Completed " + monitor.completed);

                isPrintedSuccessfully = true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        return isPrintedSuccessfully;
    }

    private static class JobCompleteMonitor extends PrintJobAdapter {
        private boolean completed = false;

        @Override
        public void printJobCanceled(PrintJobEvent pje) {
            signalCompletion();
        }

        @Override
        public void printJobCompleted(PrintJobEvent pje) {
            signalCompletion();
        }

        @Override
        public void printJobFailed(PrintJobEvent pje) {
            signalCompletion();
        }

        @Override
        public void printJobNoMoreEvents(PrintJobEvent pje) {
            signalCompletion();
        }

        private void signalCompletion() {
            synchronized(JobCompleteMonitor.this) {
                completed = true;
                JobCompleteMonitor.this.notify();
            }
        }

        public synchronized void waitForJobCompletion() {
            try {
                while (!completed) {
                    wait();
                }
            } catch (InterruptedException e) {

            }
        }
    }
}

read more

Unable to run Plone site

I am using Plone for my site When i am trying to run following command it gets an error :
Plone/zinstance $ bin/instance fg

Traceback (most recent call last):

File "/Plone/zinstance/parts/instance/bin/interpreter", line 297, in <module>
    exec(compile(__file__f.read(), __file__, "exec"))
  File "/Plone/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/run.py", line 76, in <module>
    run(/Plone/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/run.py", line 22, in run
    starter.prepare()
  File "/home/turningcloud/Plone/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/__init__.py", line 79, in prepare
    self.setupServers()
  File "/Plone/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/__init__.py", line 214, in setupServers
    % (server.servertype(),e[1]))
ZConfig.ConfigurationError: There was a problem starting a server of type "HTTPServer". This may mean that your user does not have permission to bind to the port which the server is trying to use or the port may already be in use by another application. (Address already in use)

read more

How can I move a file pointer to the next line in a file?

I am attempting to write a function that reads through a line, saves each character to an array, manipulates that character array, prints the results to another file, then moves on to the next line in the file.

Some sample input/output would be as follows (the purpose of the program is to find the derivative – but that part of the code is working fine.):

INPUT:
x
4x^4
91
sinx

OUTPUT:
1
16x^3
0
cosx

The function that I have written so far:

int main(){

    FILE *inptr = fopen("functions.txt", "r");
    FILE *outptr = fopen( "derive.txt", "w");

    if(inptr)
        derive(inptr,outptr);

    return 0;
}

void derive(FILE *inptr, FILE *outptr){
    int i;
    char in = '0';
    char array[MAX];

    while((in = fgetc(inptr)) != EOF){
        for(i = 0; in != '\n'; i++){
            fscanf(inptr, "%c", &in);
            array[i] = in;
        }
        manipulate(array, outptr); // Function that finds the derivative and prints to output file
    }
}

read more

How to get the intersection of two CGPath?

I am using CAShapeLayer.path and CALayer.mask to set up image mask, i can achieve “difference set” and “union” effect for CGPath by setting

maskLayer.fillRule = kCAFillRuleEvenOdd/kCAFillRuleZero

However, how can i get the intersection of two paths? I cannot achieve it with even-odd rule

Here is an example:
enter image description here

let view = UIImageView(frame: CGRectMake(0, 0, 400, 400))
view.image = UIImage(named: "scene.jpg")
let maskLayer = CAShapeLayer()
let maskPath = CGPathCreateMutable()    
CGPathAddEllipseInRect(maskPath, nil, CGRectOffset(CGRectInset(view.bounds, 50, 50), 50, 0))
CGPathAddEllipseInRect(maskPath, nil, CGRectOffset(CGRectInset(view.bounds, 50, 50), -50, 0))
maskLayer.path = maskPath
maskLayer.fillRule = kCAFillRuleEvenOdd
maskLayer.path = maskPath
view.layer.mask = maskLayer

read more

What is social marketing? SEO blog provides tips, tricks, and advice for improving websites and doing better search, social, content, and brand digital marketing 2017