List of usage examples for java.nio IntBuffer limit
public final int limit()
From source file:Main.java
public static IntBuffer createIntBuffer(IntBuffer buf, final int size) { if (buf != null && buf.limit() == size) { buf.rewind();// w ww . ja v a 2s.co m return buf; } buf = createIntBuffer(size); return buf; }
From source file:Main.java
/** * Create a new int[] array and populate it with the given IntBuffer's * contents./* w w w . ja va 2s. com*/ * * @param buff * the IntBuffer to read from * @return a new int array populated from the IntBuffer */ public static int[] getIntArray(IntBuffer buff) { if (buff == null) { return null; } buff.clear(); int[] inds = new int[buff.limit()]; for (int x = 0; x < inds.length; x++) { inds[x] = buff.get(); } return inds; }
From source file:Main.java
public static int[] getIntArray(final IntBuffer buff) { if (buff == null) { return null; }/*from w w w . j av a 2 s. c o m*/ buff.rewind(); final int[] inds = new int[buff.limit()]; for (int x = 0; x < inds.length; x++) { inds[x] = buff.get(); } return inds; }
From source file:Main.java
public static IntBuffer clone(final IntBuffer buf) { if (buf == null) { return null; }// www . ja va 2s. com buf.rewind(); final IntBuffer copy; if (buf.isDirect()) { copy = createIntBuffer(buf.limit()); } else { copy = createIntBufferOnHeap(buf.limit()); } copy.put(buf); return copy; }
From source file:edu.csun.ecs.cs.multitouchj.audio.openal.OpenAlAudioPlayer.java
@Override public synchronized void update() { IntBuffer emptyBuffers = unqueueEmptyBuffers(); for (int i = 0; i < emptyBuffers.limit(); i++) { setBufferStatus(emptyBuffers.get(i), false); eventOccurred("bufferEmptied"); }/* ww w .j a va 2 s .c om*/ if ((!isStoppedEventSent) && (getStatus().equals(Status.STOPPED))) { eventOccurred("audioStopped"); } }
From source file:com.clov4r.moboplayer.android.nil.codec.SubtitleJni.java
public Bitmap createBitmapOfSubtitle(ByteBuffer data, int width, int height) { IntBuffer intBuffer = data.asIntBuffer(); int[] dataArray = new int[intBuffer.limit()]; intBuffer.get(dataArray);/*from ww w.j a va 2s .com*/ Bitmap rest = Bitmap.createBitmap(dataArray, width, height, Config.RGB_565); return rest; }
From source file:com.creativeongreen.imageeffects.MainActivity.java
public static Bitmap colorDodgeBlend(Bitmap source, Bitmap layer) { Bitmap base = source.copy(Config.ARGB_8888, true); Bitmap blend = layer.copy(Config.ARGB_8888, false); IntBuffer buffBase = IntBuffer.allocate(base.getWidth() * base.getHeight()); base.copyPixelsToBuffer(buffBase);/*from w w w . j a v a 2 s . c o m*/ buffBase.rewind(); IntBuffer buffBlend = IntBuffer.allocate(blend.getWidth() * blend.getHeight()); blend.copyPixelsToBuffer(buffBlend); buffBlend.rewind(); IntBuffer buffOut = IntBuffer.allocate(base.getWidth() * base.getHeight()); buffOut.rewind(); while (buffOut.position() < buffOut.limit()) { int filterInt = buffBlend.get(); int srcInt = buffBase.get(); int redValueFilter = Color.red(filterInt); int greenValueFilter = Color.green(filterInt); int blueValueFilter = Color.blue(filterInt); int redValueSrc = Color.red(srcInt); int greenValueSrc = Color.green(srcInt); int blueValueSrc = Color.blue(srcInt); int redValueFinal = colordodge(redValueFilter, redValueSrc); int greenValueFinal = colordodge(greenValueFilter, greenValueSrc); int blueValueFinal = colordodge(blueValueFilter, blueValueSrc); int pixel = Color.argb(255, redValueFinal, greenValueFinal, blueValueFinal); /* * float[] hsv = new float[3]; Color.colorToHSV(pixel, hsv); hsv[1] = 0.0f; float top = * VALUE_TOP; // Setting this as 0.95f gave the best result so far if (hsv[2] <= top) { * hsv[2] = 0.0f; } else { hsv[2] = 1.0f; } pixel = Color.HSVToColor(hsv); */ buffOut.put(pixel); } buffOut.rewind(); base.copyPixelsFromBuffer(buffOut); blend.recycle(); return base; }
From source file:com.creativeongreen.imageeffects.MainActivity.java
public static Bitmap getCartoonizedBitmap(Bitmap realBitmap, Bitmap dodgeBlendBitmap, int hueIntervalSize, int saturationIntervalSize, int valueIntervalSize, int saturationPercent, int valuePercent) { // Bitmap bitmap = Bitmap.createBitmap(scaledBitmap); // //fastblur(scaledBitmap, 4); Bitmap base = fastblur(realBitmap, 3).copy(Config.ARGB_8888, true); Bitmap dodge = dodgeBlendBitmap.copy(Config.ARGB_8888, false); try {/* www . j a va 2s.c o m*/ int realColor; int color; float top = 0.87f;// VALUE_TOP; // Between 0.0f .. 1.0f I use 0.87f IntBuffer templatePixels = IntBuffer.allocate(dodge.getWidth() * dodge.getHeight()); IntBuffer scaledPixels = IntBuffer.allocate(base.getWidth() * base.getHeight()); IntBuffer buffOut = IntBuffer.allocate(base.getWidth() * base.getHeight()); base.copyPixelsToBuffer(scaledPixels); dodge.copyPixelsToBuffer(templatePixels); templatePixels.rewind(); scaledPixels.rewind(); buffOut.rewind(); while (buffOut.position() < buffOut.limit()) { color = (templatePixels.get()); realColor = scaledPixels.get(); float[] realHSV = new float[3]; Color.colorToHSV(realColor, realHSV); realHSV[0] = getRoundedValue(realHSV[0], hueIntervalSize); realHSV[2] = (getRoundedValue(realHSV[2] * 100, valueIntervalSize) / 100) * (valuePercent / 100); realHSV[2] = realHSV[2] < 1.0 ? realHSV[2] : 1.0f; realHSV[1] = realHSV[1] * (saturationPercent / 100); realHSV[1] = realHSV[1] < 1.0 ? realHSV[1] : 1.0f; float[] HSV = new float[3]; Color.colorToHSV(color, HSV); boolean putBlackPixel = HSV[2] <= top; realColor = Color.HSVToColor(realHSV); if (putBlackPixel) { buffOut.put(color); } else { buffOut.put(realColor); } } // END WHILE dodge.recycle(); buffOut.rewind(); base.copyPixelsFromBuffer(buffOut); } catch (Exception e) { // TODO: handle exception } return base; }