Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-02-17 00:44:18 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-02-17 00:44:18 +0300
commit39ea873a8bc91a7fc4df7b1fa7a7a18239fddae1 (patch)
tree68a81953a98bc282e804c924b32781230ee74af1 /source/blender/freestyle/intern/application/AppCanvas.cpp
parentca908e21e215a87f0783fed47feed394ccdea4d6 (diff)
Fixed bugs in AppCanvas::readColorPixels() and
AppCanvas::readDepthPixels() that caused a crash when the aspect ratio was not 1:1.
Diffstat (limited to 'source/blender/freestyle/intern/application/AppCanvas.cpp')
-rwxr-xr-xsource/blender/freestyle/intern/application/AppCanvas.cpp84
1 files changed, 48 insertions, 36 deletions
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index 4ee7244a7dd..4d4ab33cc59 100755
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -111,46 +111,58 @@ void AppCanvas::Erase()
void AppCanvas::readColorPixels(int x,int y,int w, int h, RGBImage& oImage) const
{
- float *rgb = new float[3*w*h];
- memset(rgb, 0, sizeof(float) * 3 * w * h);
- if (_pass_diffuse) {
- int rectx = width(), recty = height();
- int i, ii, j, jj;
- for (j = 0; j < h; j++) {
- jj = y + j;
- if (jj < 0 || jj >= recty)
- continue;
- for (i = 0; i < w; i++) {
- ii = x + i;
- if (ii < 0 || ii >= rectx)
- continue;
- memcpy(rgb + (w * j + i) * 3, _pass_diffuse + (rectx * jj + ii) * 3, sizeof(float) * 3);
- }
- }
- }
- oImage.setArray(rgb, width(), height(), w,h, x, y, false);
+ float *rgb = new float[3*w*h];
+ memset(rgb, 0, sizeof(float) * 3 * w * h);
+ int xsch = width();
+ int ysch = height();
+ if (_pass_diffuse.buf) {
+ int rectx = _pass_z.width;
+ int recty = _pass_z.height;
+ float xfac = ((float)rectx) / ((float)xsch);
+ float yfac = ((float)recty) / ((float)ysch);
+ printf("readColorPixels %d x %d @ (%d, %d) in %d x %d -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch, rectx, recty, (int)(xfac * 100.0f));
+ int ii, jj;
+ for (int j = 0; j < h; j++) {
+ jj = (int)((y + j) * yfac);
+ if (jj < 0 || jj >= recty)
+ continue;
+ for (int i = 0; i < w; i++) {
+ ii = (int)((x + i) * xfac);
+ if (ii < 0 || ii >= rectx)
+ continue;
+ memcpy(rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float) * 3);
+ }
+ }
+ }
+ oImage.setArray(rgb, xsch, ysch, w, h, x, y, false);
}
void AppCanvas::readDepthPixels(int x,int y,int w, int h, GrayImage& oImage) const
{
- float *z = new float[w*h];
- memset(z, 0, sizeof(float) * w * h);
- if (_pass_z) {
- int rectx = width(), recty = height();
- int i, ii, j, jj;
- for (j = 0; j < h; j++) {
- jj = y + j;
- if (jj < 0 || jj >= recty)
- continue;
- for (i = 0; i < w; i++) {
- ii = x + i;
- if (ii < 0 || ii >= rectx)
- continue;
- z[w * j + i] = _pass_z[rectx * jj + ii];
- }
- }
- }
- oImage.setArray(z, width(), height(), w,h, x, y, false);
+ float *z = new float[w*h];
+ memset(z, 0, sizeof(float) * w * h);
+ int xsch = width();
+ int ysch = height();
+ if (_pass_z.buf) {
+ int rectx = _pass_z.width;
+ int recty = _pass_z.height;
+ float xfac = ((float)rectx) / ((float)xsch);
+ float yfac = ((float)recty) / ((float)ysch);
+ printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch, rectx, recty, (int)(xfac * 100.0f));
+ int ii, jj;
+ for (int j = 0; j < h; j++) {
+ jj = (int)((y + j) * yfac);
+ if (jj < 0 || jj >= recty)
+ continue;
+ for (int i = 0; i < w; i++) {
+ ii = (int)((x + i) * xfac);
+ if (ii < 0 || ii >= rectx)
+ continue;
+ z[w * j + i] = _pass_z.buf[rectx * jj + ii];
+ }
+ }
+ }
+ oImage.setArray(z, xsch, ysch, w, h, x, y, false);
}
void AppCanvas::RenderStroke(Stroke *iStroke) {