1
Graphics / [Solved]100% pixel perfect sf::View size?
« on: June 25, 2010, 11:09:21 am »
I tried this but it doesn't work: sf::Vector2f HalfSize(App.GetWidth()*.5f,App.GetHeight()*.5f);
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#include <SFML/Graphics.hpp>
#include <iostream>
void Color_Sort(sf::Uint8* color_ptr)
{
//wrong number(99)--How do I keep this as 5?
std::cout<<"color:"<<static_cast <int>(color_ptr[0])<<'\n';
}
int main()
{
sf::Uint8 *color_ptr=new sf::Uint8();
sf::Uint8 *num;
num[0]=5;
color_ptr=num;
//correct number:
std::cout<<"color:"<<static_cast <int>(color_ptr[0])<<'\n';
sf::Uint8 *color_ptr2=new sf::Uint8();
sf::Uint8 *num2;
num2[0]=99;
color_ptr2=num2;
Color_Sort(color_ptr);
delete[] color_ptr2;
delete[] color_ptr;
return 0;
}
sf::Uint8* Get_Pixel(sf::Uint8* img_ptr,int w,int h,int x,int y)
{
int index=(((y*h)-y)+(x))*4;
sf::Uint8 *ptr=new sf::Uint8[3];
ptr[0]=img_ptr[index];
ptr[1]=img_ptr[index+1];
ptr[2]=img_ptr[index+2];
ptr[3]=img_ptr[index+3];
return ptr;
}
sf::Uint8 *img_ptr=const_cast<sf::Uint8*>(img.GetPixelsPtr());
sf::Uint8 *ptr3=Get_Pixel(img_ptr,w,h,80,0);
Hi, here's an example of my probs, any help would be great:Code: [Select]sf::Color c1,c2;
c1=img.GetPixel(0,0);
if(c1!=c2) // doesn't compare colors
{
}