About Store Forum Documentation Contact



Post Reply 
image::crop
Author Message
Dandruff Offline
Member

Post: #1
image::crop
Can someone shed some light on what each argument of image::crop takes in?
Code:
Image& crop                (Image &dest, Int x, Int y, Int w, Int h                                    ); // crop   image !! returns 'dest'

I don't really know which arguments to pass over to the function. Eg: Does x and y = x and y of a point in the image and w and h is another point in the image and together they make a square, the cropped picture?

Esenthel is awesome
08-12-2011 04:43 AM
Find all posts by this user Quote this message in a reply
Rofar Offline
Member

Post: #2
RE: image::crop
I would guess that x and y is the origin for the rectangle area you want to crop. w and h would be the width and height of the rectangle.
08-12-2011 11:58 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: image::crop
yes
08-13-2011 04:08 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #4
RE: image::crop
Great, works perfectly, thanks
08-13-2011 10:58 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #5
RE: image::crop
Hey guys, I can't seem to get this to work. I notice the crop() function has changed a bit so perhaps I'm using it wrong. Here's what I'm doing.

Code:
bigImage.crop(smallImage, 10, 10, 0, 110, 110, 0);

I was expecting smallImage to contain the cropped version of bigImage... but it does nothing, smallImage is blank. I must be missing something. Do both images need to be locked first or only one of them... I've tried both? What should z and d be set to... I've tried 0 and 1.
02-05-2012 04:49 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: image::crop
no manual locking
please set z=0 and d=1
02-06-2012 12:55 PM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #7
RE: image::crop
Hi, check my sample based on EE tutorial (Image.cpp) (Just copy and paste it.) and tell me why Image::crop() doesn't work ?

Why image2 is black?

When i did export [image2] to (PNG) content is correct. So why i can't draw it ?

Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Image image, image2; // image object
/******************************************************************************/
void InitPre()
{
   App.name("Image");
   Paks.add("../data/engine.pak");
}
/******************************************************************************/
Bool Init()
{
   image.load("../data/particle/star.gfx"); // load image from file
   image.crop(image2, 0,0,0, 64,64,1);

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;

   if(Kb.bp(KB_S))image2.ExportPNG("LocalData/image2.png");
   return true;
}
/******************************************************************************/
void Draw()
{
   D.clear(BLUE);

   TextDS tds;

   D.text(tds, 0,0.7,S+"Press S to export LocalData/image2.png");

   // draw image
   image.draw(Rect(-1.0f, -1.0f, 0.5f, 0.5f)); // draw at given rectangle
   image2.draw(Rect(0.0f, 0.0f, 0.5f, 0.5f));


}
/******************************************************************************/

[Image: image1xn.jpg]
[Image: image2rr.jpg]
05-30-2012 05:34 PM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #8
RE: image::crop
bump! nobody ? :(
06-01-2012 04:33 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #9
RE: image::crop
The only problem could be is that the .gfx was exported in the wrong format and does not support an alpha channel.

What about loading the .png file?
06-02-2012 11:44 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #10
RE: image::crop
omg my fault xD sory for confusion
Code:
image.Import("../Data/Gfx/landscape.png", IMAGE_B8G8R8A8, IMAGE_2D );
06-02-2012 12:07 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: image::crop
Thanks,
there is an error in the crop method which may result in output image being of IMAGE_SOFT and not the original IMAGE_MODE.
I will fix it for next SDK
06-02-2012 01:49 PM
Find all posts by this user Quote this message in a reply
veksha Offline
Member

Post: #12
RE: image::crop
hi. was this fixed? i guess not.
07-06-2023 11:45 PM
Find all posts by this user Quote this message in a reply
Post Reply