%ffp //---------------------------------- // MemoryAllocTest //---------------------------------- Title: "MemoryAllocTest" Description: "MemoryAllocTest" Filename: "MemoryAllocTest" Version: "v0.35a (12/29/2001)" Category: "DrTOtalREC's Filters" Copyright: "Copyright ©2001" Author: "Ron Chambers" Organization: "DrTOtalREC Filters" URL: "mailto://rfchmbrs@swbell.net" About: "DrTOtalREC's !T !V\n!c !A \n!U\nDonate to BREAST CANCER RESEARCH" Dialog: Text = "DrTOtalREC's !T !V !c !A", Color=darkblue, Gradient=(midnightblue, mediumblue, v) // ------- ForEveryTile: { int type, offset; int ui_x, ui_y, ui_dx, ui_dy, ii, ij; // ------- double *dbuffer; double dvalue = 0.0; int dleng = 8; // ------- unsigned int *fbuffer; unsigned int fvalue = 0.0; int fleng = 4; // ------- int *ibuffer; int ivalue = 0; int ileng = 4; // ------- word *wbuffer; word wvalue = 0; int wleng = 2; // ------- byte *bbuffer; byte bvalue = 0; int bleng = 1; //------ //------ if(i5==0) { i5 = 1; ij = -1; ui_dx = 80; ui_dy = 10; ui_x = 235; ui_y = 0; //------ ij++; ui_y += ui_dy+2; snprintf( str9[0], 25, "%s", "Byte x%20"); snprintf( str9[25], 1, "%s", ""); createCtl(ij, CC_CHECKBOX, str9, ui_x, ui_y, ui_dx, ui_dy, 3, 0, 0, -1); setCtlToolTip(ij, str9, 0); setCtlVal(ij, 0); setCtlAction(ij, CA_NONE); //------ ij++; ui_y += ui_dy+2; snprintf( str9[0], 25, "%s", "Word y%20"); snprintf( str9[25], 1, "%s", ""); createCtl(ij, CC_CHECKBOX, str9, ui_x, ui_y, ui_dx, ui_dy, 3, 0, 0, -1); setCtlToolTip(ij, str9, 0); setCtlVal(ij, 0); setCtlAction(ij, CA_NONE); //------ ij++; ui_y += ui_dy+2; snprintf( str9[0], 25, "%s", "Int x%20 y%20"); snprintf( str9[25], 1, "%s", ""); createCtl(ij, CC_CHECKBOX, str9, ui_x, ui_y, ui_dx, ui_dy, 3, 0, 0, -1); setCtlToolTip(ij, str9, 0); setCtlVal(ij, 0); setCtlAction(ij, CA_NONE); //------ ij++; ui_y += ui_dy+2; snprintf( str9[0], 25, "%s", "Unsigned Int x%40"); snprintf( str9[25], 1, "%s", ""); createCtl(ij, CC_CHECKBOX, str9, ui_x, ui_y, ui_dx, ui_dy, 3, 0, 0, -1); setCtlToolTip(ij, str9, 0); setCtlVal(ij, 0); setCtlAction(ij, CA_NONE); //------ ij++; ui_y += ui_dy+2; snprintf( str9[0], 25, "%s", "Double x%40 y%40"); snprintf( str9[25], 1, "%s", ""); createCtl(ij, CC_CHECKBOX, str9, ui_x, ui_y, ui_dx, ui_dy, 3, 0, 0, -1); setCtlToolTip(ij, str9, 0); setCtlVal(ij, 0); setCtlAction(ij, CA_NONE); //------ ui_y += ui_dy+8; createCtl(113, CC_PUSHBUTTON, "Preview", ui_x,ui_y, ui_dx, ui_dy, 0, 0, 0, 3); setCtlAction(113, CA_PREVIEW); setCtlToolTip(113, "Preview-shows the effects on the image in the preview window.", 0); //------ ui_y += ui_dy+2; createCtl(CTL_OK, CC_PUSHBUTTON, "Apply", ui_x,ui_y, ui_dx, ui_dy, 0, 0, 0, 3); setCtlAction(CTL_OK, CA_APPLY); setCtlToolTip(CTL_OK, "Apply-applies the parameters to the image.", 0); //------ ui_y += ui_dy+2; createCtl(CTL_CANCEL, CC_PUSHBUTTON, "Cancel", ui_x,ui_y, ui_dx, ui_dy, 0, 0, 0, 3); setCtlAction(CTL_CANCEL, CA_CANCEL); setCtlToolTip(CTL_CANCEL, "Cancel-cancels the action and returns to the image processing program.", 0); //------ ui_y += ui_dy+2; createCtl(CTL_LOGO, CC_PUSHBUTTON, "About", ui_x,ui_y, ui_dx, ui_dy, 0, 0, 0, 3); setCtlAction(CTL_LOGO, CA_ABOUT); setCtlToolTip(CTL_LOGO, "About-shows in the About window filter and author information.", 0); } // ------- ij = 0; type = ctl(ij++) * 1 + ctl(ij++) * 2 + ctl(ij++) * 4 + ctl(ij++) * 6 + ctl(ij++) * 8; // ------- if(!i2 || i3 != scaleFactor) { i3 = scaleFactor; i4 = type; // ------- switch (type) { case 1: if(!(bbuffer = malloc(X * Y * zmax * bleng))) { Info("Buffering error"); } i2 = bbuffer; break; case 2: if(!(wbuffer = malloc(X * Y * zmax * wleng))) { Info("Buffering error"); } i2 = wbuffer; break; case 4: if(!(ibuffer = malloc(X * Y * zmax * ileng))) { Info("Buffering error"); } i2 = ibuffer; break; case 6: if(!(fbuffer = malloc(X * Y * zmax * fleng))) { Info("Buffering error"); } i2 = fbuffer; break; case 8: if(!(dbuffer = malloc(X * Y * zmax * dleng))) { Info("Buffering error"); } i2 = dbuffer; break; } // ------- for(y = 0; y < Y; ++y) { for(x = 0; x < X; ++x) { for(z = 0; z < zmax; ++z) { offset = ((((y * X) + x) * zmax) + z); switch (type) { case 1: bvalue = src(x, y, z) + x%20; memcpy(i2 + (offset * bleng), &bvalue, bleng); break; case 2: wvalue = src(x, y, z) + y%20; memcpy(i2 + (offset * wleng), &wvalue, wleng); break; case 4: ivalue = src(x, y, z) + x%20 + y%20; memcpy(i2 + (offset * ileng), &ivalue, ileng); break; case 6: fvalue = src(x, y, z) + x%40; memcpy(i2 + (offset * fleng), &fvalue, fleng); break; case 8: dvalue = (double)(src(x, y, z) + x%40 + y%40); memcpy(i2 + (offset * dleng), &dvalue, dleng); break; } } } if(updateProgress(y, Y * 2)) abort(); } // ------- for(y = 0; y < Y; ++y) { for(x = 0; x < X; ++x) { for(z = 0; z < zmax; ++z) { offset = ((((y * X) + x) * zmax) + z); switch (type) { case 1: memcpy(&bvalue, i2 + (offset * bleng), bleng); pset(x, y, z, bvalue); break; case 2: memcpy(&wvalue, i2 + (offset * wleng), wleng); pset(x, y, z, wvalue); break; case 4: memcpy(&ivalue, i2 + (offset * ileng), ileng); pset(x, y, z, ivalue); break; case 6: memcpy(&fvalue, i2 + (offset * fleng), fleng); pset(x, y, z, fvalue); break; case 8: memcpy(&dvalue, i2 + (offset * dleng), dleng); pset(x, y, z, (int)dvalue); break; } } } if(updateProgress(Y + y, Y * 2)) abort(); } } if(i2!=0) { free(i2); i2 = 0; } return true; } %%eof