MCPcopy Index your code
hub / github.com/processing/processing / blit_resize

Method blit_resize

core/src/processing/core/PImage.java:1930–2416  ·  view source on GitHub ↗

Internal blitter/resizer/copier from toxi. Uses bilinear filtering if smooth() has been enabled 'mode' determines the blending mode used in the process.

(PImage img,
                           int srcX1, int srcY1, int srcX2, int srcY2,
                           int[] destPixels, int screenW, int screenH,
                           int destX1, int destY1, int destX2, int destY2,
                           int mode)

Source from the content-addressed store, hash-verified

1928 * 'mode' determines the blending mode used in the process.
1929 */
1930 private void blit_resize(PImage img,
1931 int srcX1, int srcY1, int srcX2, int srcY2,
1932 int[] destPixels, int screenW, int screenH,
1933 int destX1, int destY1, int destX2, int destY2,
1934 int mode) {
1935 if (srcX1 < 0) srcX1 = 0;
1936 if (srcY1 < 0) srcY1 = 0;
1937 if (srcX2 > img.pixelWidth) srcX2 = img.pixelWidth;
1938 if (srcY2 > img.pixelHeight) srcY2 = img.pixelHeight;
1939
1940 int srcW = srcX2 - srcX1;
1941 int srcH = srcY2 - srcY1;
1942 int destW = destX2 - destX1;
1943 int destH = destY2 - destY1;
1944
1945 boolean smooth = true; // may as well go with the smoothing these days
1946
1947 if (!smooth) {
1948 srcW++; srcH++;
1949 }
1950
1951 if (destW <= 0 || destH <= 0 ||
1952 srcW <= 0 || srcH <= 0 ||
1953 destX1 >= screenW || destY1 >= screenH ||
1954 srcX1 >= img.pixelWidth || srcY1 >= img.pixelHeight) {
1955 return;
1956 }
1957
1958 int dx = (int) (srcW / (float) destW * PRECISIONF);
1959 int dy = (int) (srcH / (float) destH * PRECISIONF);
1960
1961 srcXOffset = destX1 < 0 ? -destX1 * dx : srcX1 * PRECISIONF;
1962 srcYOffset = destY1 < 0 ? -destY1 * dy : srcY1 * PRECISIONF;
1963
1964 if (destX1 < 0) {
1965 destW += destX1;
1966 destX1 = 0;
1967 }
1968 if (destY1 < 0) {
1969 destH += destY1;
1970 destY1 = 0;
1971 }
1972
1973 destW = min(destW, screenW - destX1);
1974 destH = min(destH, screenH - destY1);
1975
1976 int destOffset = destY1 * screenW + destX1;
1977 srcBuffer = img.pixels;
1978
1979 if (smooth) {
1980 // use bilinear filtering
1981 iw = img.pixelWidth;
1982 iw1 = img.pixelWidth - 1;
1983 ih1 = img.pixelHeight - 1;
1984
1985 switch (mode) {
1986
1987 case BLEND:

Callers 1

blendMethod · 0.95

Calls 15

minMethod · 0.95
filter_new_scanlineMethod · 0.95
blend_blendMethod · 0.95
filter_bilinearMethod · 0.95
blend_add_pinMethod · 0.95
blend_sub_pinMethod · 0.95
blend_lightestMethod · 0.95
blend_darkestMethod · 0.95
blend_differenceMethod · 0.95
blend_exclusionMethod · 0.95
blend_multiplyMethod · 0.95
blend_screenMethod · 0.95

Tested by

no test coverage detected