Buffers

CreatePictureEx, StretchBlt, StretchBltRGB

CreatePictureEx

Description 

 CreatePictureEx(
   int  picconst,
   int  picflag,
   int  Width,
   int  Height
);

This function creates or removes additional pictures.

Parameters

int picconst

Picture offset + index.

PIC_OFFSET

Additional picture.

int picflag

Picture create/remove flag.

PIC_CREATE

Create picture.

PIC_REMOVE

Remove picture.

int Width

Image width in pixels.

int Height

Image height in pixels.

Return Values

This function returns true if successful and false if failed.

Note

With this function you can create or remove the picture. The standard limit of additional pictures is 5. The pictures are handled via constants. There can be created up to 128 additional pictures. The first picture has the value PIC_OFFSET + 0, the last picture has the value PIC_OFFSET + 127. If you try to create already created picture, FALSE value will be returned. Every new created picture increases the amount of allocated memory so it can less the performance of the system. All created pictures are automatically removed at the end of the NIS-Elements session, but if you do not intend to use the created picture any more, you should remove the picture from the system.

See Also 
StretchBlt

StretchBlt

Description 

int StretchBlt(
   int  c_dest,
   int  c_sour,
   int  c_mode,
   int  X2,
   int  Y2,
   int  width2,
   int  Height2,
   int  X1,
   int  Y1,
   int  width1,
   int  Height1,
   int  visible
);

This function performs copying, exchanging and rescaling on the defined pictures.

X2 parameter is the left and Y2 is the right destination rectangle coordinate.

Parameters

int c_dest

Destination picture.

0, PICTURE_CURRENT

Current picture.

1, PICTURE_RESULT

Result picture.

2, PICTURE_REFERENCE

Reference picture.

3, PICTURE_OVERLAY

Overlay picture.

int c_sour

Source picture.

0, PICTURE_CURRENT

Current picture.

1, PICTURE_RESULT

Result picture.

2, PICTURE_REFERENCE

Reference picture.

3, PICTURE_OVERLAY

Overlay picture.

int c_mode

Mode operation.

0, MODE_COPY

Copy from source to destination.

1, MODE_EXCHANGE

Exchange source and destination.

int X2

X coordinate in pixels.

int Y2

Y coordinate in pixels.

int width2

Destination rectangle width.

int Height2

Height (in pixels) of the destination rectangle in the picture window.

int X1

X coordinate in pixels.

int Y1

Y coordinate in pixels.

int width1

Source rectangle width.

int Height1

Height (in pixels) of the source rectangle in the image data.

int visible

If this parameter is greater than zero and the destination is PICTURE_CURRENT (0), the current image is shown after the operation.

-1, NOCHANGE_NOSHOW

Not processed components are not changed,picture is not showed.

0, CHANGE_NOSHOW

Not processed components have zero value,picture is not showed.

1, CHANGE_SHOW

Not processed components have zero value,picture is showed.

2, NOCHANGE_SHOW

Not processed components are not changed,picture is showed.

Return Values

int

This function returns TRUE (1) if parameters are reasonable, otherwise it returns FALSE (0).

// StretchBlt example - shows different edge detection methods in quadrants. It behaves correclty to Undo.
int      xs,ys,width,height;
int      i1,i2,x1,y1,i2_,i1_;
int      p_w,p_h;
int      qw;
char     oper[1024],caption[256]; 
dword    time1,time2;  
Int_CreateTextWindow("API Example - StretchBlt function.",0,RGB(0,0,128),RGB_WHITE,100);
SetCommandText("Working...");
Get_Size(SIZE_PICWND,&xs,&ys,&width,&height);
_ImageOpen();
qw = Int_Question("API Demo","Set stretch mode:","Quick","Splines","","",1,0);
if(qw == 1) SetStretchMode(STRETCH_QUICK);
if(qw == 2) SetStretchMode(STRETCH_SPLINES);
p_w = width / 2;
p_h = height / 2;
SuppressDisplay();
Int_CreateTextWindow("Original Image",0,RGB(0,0,128),RGB_WHITE,100);
x1 = (p_w * i2);
y1 = (p_h * i1);
StretchBlt(PICTURE_OVERLAY,PICTURE_CURRENT,MODE_COPY,0,0,0,0,0,0,0,0,0);
StretchBlt(PICTURE_REFERENCE,PICTURE_CURRENT,MODE_COPY,0,0,p_w,p_h,0,0,width,height,0); 
Int_CreateTextWindow("Morpho Gradient - Octagon 2x",0,RGB(0,0,128),RGB_WHITE,100);
MorphoGradientEx(-2,4);
StretchBlt(PICTURE_REFERENCE,PICTURE_CURRENT,MODE_COPY,p_w,0,p_w,p_h,0,0,width,height,0);
StretchBlt(PICTURE_CURRENT,PICTURE_OVERLAY,MODE_COPY,0,0,0,0,0,0,0,0,0);
Int_CreateTextWindow("Edge Detection - Sobel",0,RGB(0,0,128),RGB_WHITE,100);
EdgeDetect();
StretchBlt(PICTURE_REFERENCE,PICTURE_CURRENT,MODE_COPY,0,p_h,p_w,p_h,0,0,width,height,0); 
StretchBlt(PICTURE_CURRENT,PICTURE_OVERLAY,MODE_COPY,0,0,0,0,0,0,0,0,0);
Int_CreateTextWindow("Edge Detection - Golay",0,RGB(0,0,128),RGB_WHITE,100);
GolayFilter(5,3);
StretchBlt(PICTURE_REFERENCE,PICTURE_CURRENT,MODE_COPY,p_w,p_h,p_w,p_h,0,0,width,height,0); 
StretchBlt(PICTURE_CURRENT,PICTURE_REFERENCE,MODE_EXCHANGE,0,0,0,0,0,0,0,0,0);
Int_CreateTextWindow("Inserting Descriptions",0,RGB(0,0,128),RGB_WHITE,100);
InsertText("          Original          ",0,0,0,0,0,"Arial",-13,1,0,0,0,0);
InsertText(" Morpho Gradient Octagon 2x ",p_w,0,0,0,0,"Arial",-13,1,0,0,0,0);
InsertText("   Edge Detection - Sobel   ",0,p_h,0,0,0,"Arial",-13,1,0,0,0,0);
InsertText("   Edge Detection - Golay   ",p_w,p_h,0,0,0,"Arial",-13,1,0,0,0,0);
StretchBlt(PICTURE_RESULT,PICTURE_OVERLAY,MODE_COPY,0,0,0,0,0,0,0,0,0); 
if(ExistProc("ViewColor")) ViewColor();
else ViewGray();
Int_CloseTextWindow();

Note

The exchanges are made only on whole pictures. You change the stretch mode manually in Preferences dialog box, Macro menu. Areas outside the pictures are clipped.

See Also 
StretchBltRGB, StretchToReference

StretchBltRGB

Description 

int StretchBltRGB(
   int  c_dest,
   int  c_sour,
   int  c_mode,
   int  X2,
   int  Y2,
   int  width2,
   int  Height2,
   int  X1,
   int  Y1,
   int  width1,
   int  Height1,
   int  col_to,
   int  col_from,
   int  visible
);

This function performs copying, exchanging and rescaling on defined pictures. This function respects color components and can be used only in the application.

X2 parameter is the left and Y2 is the right destination rectangle coordinate.

Parameters

int c_dest

Destination picture.

0, PICTURE_CURRENT

Current picture.

1, PICTURE_RESULT

Result picture.

2, PICTURE_REFERENCE

Reference picture.

3, PICTURE_OVERLAY

Overlay picture.

int c_sour

Source picture.

0, PICTURE_CURRENT

Current picture.

1, PICTURE_RESULT

Result picture.

2, PICTURE_REFERENCE

Reference picture.

3, PICTURE_OVERLAY

Overlay picture.

int c_mode

Mode operation.

0, MODE_COPY

Copy from source to destination.

1, MODE_EXCHANGE

Exchange source and destination.

int X2

X coordinate in pixels.

int Y2

Y coordinate in pixels.

int width2

Destination rectangle width.

int Height2

Height (in pixels) of the destination rectangle in the picture window.

int X1

X coordinate in pixels.

int Y1

Y coordinate in pixels.

int width1

Source rectangle width.

int Height1

Height (in pixels) of the source rectangle in the image data.

int col_to

Destination color components. Constants can be used with or operation.

4, RED_COMP

Red component.

2, GREEN_COMP

Green component.

1, BLUE_COMP

Blue component.

int col_from

Source color components. Constants can be used with or operation.

4, RED_COMP

Red component.

2, GREEN_COMP

Green component.

1, BLUE_COMP

Blue component.

int visible

If this parameter is greater than zero and the destination is PICTURE_CURRENT (0), the current image is shown after the operation.

-1, NOCHANGE_NOSHOW

Not processed components are not changed,picture is not showed.

0, CHANGE_NOSHOW

Not processed components have zero value,picture is not showed.

1, CHANGE_SHOW

Not processed components have zero value,picture is showed.

2, NOCHANGE_SHOW

Not processed components are not changed,picture is showed.

Return Values

int

This function returns TRUE (1) if parameters are reasonable, otherwise it returns FALSE (0).

// StretchBltRGB example - shows how to use the StretchBltRGB function.
int         qw,flg_from,flg_to;
char        caption[256];
int         xs,ys,width,height;
int         x1,y1,w1,h1,x2,y2,w2,h2;
int         f_comp,t_comp,visi;
strcpy(caption,"API Example - StretchBltRGB function.");
_ImageOpen();
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
SetCommandText("Working...");
StretchBlt(PICTURE_OVERLAY,PICTURE_CURRENT,MODE_COPY,0,0,0,0,0,0,0,0,0);
StretchBlt(PICTURE_REFERENCE,PICTURE_CURRENT,MODE_COPY,0,0,0,0,0,0,0,0,0);
Get_Size(SIZE_PICWND,&xs,&ys,&width,&height);
qw = Int_Question("API Example","From:","Whole screen","Define...","","",1,0);
if(qw==BUTTON_1)
   {
   x1=0;
   y1=0;
   w1=width;
   h1=height;
   }
if(qw==BUTTON_2)
   {
   Int_DrawRectangle(RECT_HOLLOW, RGB_DEFAULT, &x1, &y1, &w1, &h1, FALSE);   
   }
qw = Int_Question("API Demo","To:","Whole screen","Define...","","",1,0);
if(qw==BUTTON_1)
   {
   x2=0;
   y2=0;
   w2=width;
   h2=height;
   }
if(qw==BUTTON_2)
   {
   Int_DrawRectangle(RECT_HOLLOW, RGB_DEFAULT, &x2, &y2, &w2, &h2, FALSE);   
   }
qw = Int_Question("API Demo","From component:","Red","Green","Blue","",1,0);
if(qw==BUTTON_1)
   {
   f_comp=RED_COMP;
   }
if(qw==BUTTON_2)
   {
   f_comp=GREEN_COMP;
   }
if(qw==BUTTON_3)
   {
   f_comp=BLUE_COMP;
   }
qw = Int_Question("API Demo","To component:","Single","Multiple","All","",1,0);
if(qw==1)
   {
   qw = Int_Question("API Demo","To component:","Red","Green","Blue","",1,0);
   if(qw==BUTTON_1)
   {
   t_comp=RED_COMP;
   }
   if(qw==BUTTON_2)
   {
   t_comp=GREEN_COMP
   }
   if(qw==BUTTON_3)
   {
   t_comp=BLUE_COMP;
   }
   goto again;
   }
if(qw==2)
   {
   qw = Int_Question("API Demo","To components:","Red and Green","Red and Blue","Blue and Green","",1,0);
   if(qw==BUTTON_1)
   {
   t_comp=RED_COMP|GREEN_COMP;
   }
   if(qw==BUTTON_2)
   {
   t_comp=RED_COMP|BLUE_COMP;
   }
   if(qw==BUTTON_3)
   {
   t_comp=BLUE_COMP|GREEN_COMP;
   }
   goto again;
   }
if(qw==BUTTON_3)
   {
   t_comp=RED_COMP|GREEN_COMP|BLUE_COMP;
   }
again:
qw = Int_Question("API Demo","Affect other components?","Yes","No","","",1,0);
if(qw==BUTTON_1)
   {
   visi=CHANGE_SHOW;
   }
if(qw==BUTTON_2)
   {
   visi=NOCHANGE_SHOW;
   }
// Copying reference image to the current image.
StretchBltRGB(PICTURE_CURRENT,PICTURE_REFERENCE,MODE_COPY,x2,y2,w2,h2,x1,y1,w1,h1,t_comp,f_comp,visi);   
// Copying original image to Undo image.
StretchBlt(PICTURE_RESULT,PICTURE_OVERLAY,MODE_COPY,0,0,0,0,0,0,0,0,0);
Int_CloseTextWindow();

Note

The exchanges are made only on whole pictures. You change the stretch mode either by calling SetStretchMode function or manually in Preferences dialog box, Macro menu. Areas outside the pictures are clipped.

See Also 
StretchBlt