예제 #1
0
    def doInBackground(self, params):

        w, h, self.position = params

        bitmap = self.getSpriteBitmap()

        width = bitmap.getWidth()
        height = bitmap.getHeight()

        xscale = w / float(width)
        yscale = h / float(height)
        scale = Math.min(xscale, yscale)

        if 0 < scale < 1:
            sw = Math.max(1, scale * width)
            sh = Math.max(1, scale * height)

            bitmap = Bitmap.createScaledBitmap(bitmap, sw, sh, True)

        elif scale >= 2:
            s = Math.min(int(Math.floor(scale)), 3)
            sw = Math.max(1, s * width)
            sh = Math.max(1, s * height)
            bitmap = Bitmap.createScaledBitmap(bitmap, sw, sh, False)

        preview = self.emptyBitmap(w, h, True)

        canvas = Canvas(preview)
        canvas.drawBitmap(bitmap, (w - bitmap.getWidth()) / 2,
                          (h - bitmap.getHeight()) / 2, self.paint)

        return preview
예제 #2
0
def resize(im,factor):
	IJ.run(im, 'Size...', 'width=' + str(int(Math.floor(im.width * factor))) + ' height=' + str(int(Math.floor(im.height * factor))) + ' average interpolation=Bicubic')
	return im
                                 itemmbo.getString("RECEIPTTOLERANCE"),
                                 MboConstants.NOACCESSCHECK)
                else:
                    mbo.setValue("RECEIPTTOLERANCE", 35,
                                 MboConstants.NOACCESSCHECK)
    elif mbo.getString("LINETYPE") in ("MATERIAL", "TOOL"):
        mbo.setValue("RECEIPTTOLERANCE", 0, MboConstants.NOACCESSCHECK)
    elif mbo.getString("LINETYPE") == "STDSERVICE" and mbo.getString(
            "ITEMNUM") in ("FREIGHT", "RESTOCK FEE DIS", "RESTOCK FEE TRN"):
        mbo.setValue("RECEIPTTOLERANCE", 0, MboConstants.NOACCESSCHECK)


if onadd or onupdate:
    setTolerance()
    receipttolrence = mbo.getInt("RECEIPTTOLERANCE")
    if not mbo.isNull("RECEIPTTOLERANCE"):
        mbo.setValue("RECEIPTTOLQTY", (orderqty * receipttolrence / 100),
                     MboConstants.NOACCESSCHECK | MboConstants.NOACTION)
elif mbo.isModified("ITEMNUM") or mbo.isModified("STORELOC") or mbo.isModified(
        "ORDERQTY"):
    setTolerance()
    receipttolrence = mbo.getInt("RECEIPTTOLERANCE")

# Set RECEIPTTOLQTY to lowest whole number irrespective of Receipt Tolerance

if (receipttolqty <> "" and receipttolqty is not None and receipttolqty <> 0):
    receipttolqty = mbo.getDouble("RECEIPTTOLQTY")
    mbo.setValue("RECEIPTTOLQTY", Math.floor(receipttolqty),
                 MboConstants.NOACCESSCHECK)
    mbo.setValue("RECEIPTTOLERANCE", receipttolrence,
                 MboConstants.NOACCESSCHECK | MboConstants.NOACTION)
                x.split('\t')[0] for x in lines
                if (str(mFOV + 1).zfill(6) + '_' + str(sFOV + 1).zfill(3)) in x
            ][0]

        # paths of the same sFOV in the first and in the second shift
        im_path_1 = os.path.join(root, shiftFolderNames[0], path_tail_1)
        im_path_2 = os.path.join(root, shiftFolderNames[shift_n], path_tail_2)

        im_1 = IJ.openImage(im_path_1)
        im_2 = IJ.openImage(im_path_2)

        # im_1.show()
        # im_2.show()

        # use the last 10% on the right of im_1 in order to align im_1 to im_2
        start_of_last_10_pct_of_im_1 = Math.floor(0.9 * (im_1.getWidth()))

        # extracting the 10% right vertical band of im_1
        #           _
        # *********|*|
        # *********|*|
        # *********|*|
        # *********|*|
        # *********|*|
        # *********|*|
        #           -

        last_10_pct_of_im_1 = crop(
            im_1,
            Roi(start_of_last_10_pct_of_im_1, 0,
                im_1.getWidth() - start_of_last_10_pct_of_im_1 + 1,