Log in

View Full Version : Bitmaps



Yago
04-22-2011, 10:41 PM
Is there a way to get a bitmap from a web page and set it as a variable?

Sex
04-22-2011, 11:07 PM
Yes.

Edit: I can't remember how I did it....
Edit2: Here (http://villavu.com/forum/showthread.php?t=41899) is something I made like 2 years ago. It worked with SCAR, not sure about Simba. Omg, that isn't the same as what you wanted D:
Maybe, a combination of that and LoadBitmap though? :)

Edit3: So many edits..I see a lot of things wrong with that function now that I am familiar with Linux :p. Like lowercase filename and shit.
Do you want me to write a new one or you think you got it? Basically, getpage the bitmap, save, and LoadBitmap.

Yago
04-23-2011, 04:24 AM
I see, but that function downloads the actual image... Is ere a way to just use it such as

S := getpage(blah)
Bitmapvar := blah...

Dgby714
04-23-2011, 04:46 AM
function BitmapFromWeb(Web: string): integer;
var
Data: string;
FileNum: integer;
begin
Data := GetPage(Web);

if (FileExists(IncludePath + 'temp.bmp')) then
FileNum := RewriteFile(IncludePath + 'temp.bmp', True)
else
FileNum := CreateFile(IncludePath + 'temp.bmp');
WriteFileString(FileNum, Data);
CloseFile(FileNum);

Result := LoadBitmap(IncludePath +'temp.bmp');
end;

cycrosism
04-23-2011, 06:22 AM
Check my sig for my bitmap tutorial, i have quite a few things but nothing on this, sorry. What Dgby714 posted should work fine

Yago
04-23-2011, 03:35 PM
function BitmapFromWeb(Web: string): integer;
var
Data: string;
FileNum: integer;
begin
Data := GetPage(Web);

if (FileExists(IncludePath + 'temp.bmp')) then
FileNum := RewriteFile(IncludePath + 'temp.bmp', True)
else
FileNum := CreateFile(IncludePath + 'temp.bmp');
WriteFileString(FileNum, Data);
CloseFile(FileNum);

Result := LoadBitmap(IncludePath +'temp.bmp');
end;


Thanks a lot Dgby714. :)

Do you think people would mind having an extra bitmap on their computer? Or should I delete it after running a script?

Sex
04-23-2011, 07:30 PM
No, it is easier on the servers. They should keep it on their computer :).

Yago
04-23-2011, 08:45 PM
I keep getting an error doing this...:

function BitmapFromWeb(Web: string): integer;
var
Data: string;
FileNum: integer;
begin
Data := GetPage(Web);

if (FileExists(IncludePath + 'CookPaint.bmp')) then
FileNum := RewriteFile(IncludePath + 'CookPaint.bmp', True)
else
FileNum := CreateFile(IncludePath + 'CookPaint.bmp');
WriteFileString(FileNum, Data);
CloseFile(FileNum);

Result := LoadBitmap(IncludePath +'CookPaint.bmp');
end;

var
Chat: Integer;

begin
Chat := BitmapFromWeb('http://img153.imageshack.us/f/lcpaint.png/');
end.

Error:

Exception: Error while reading stream: Wrong image format at line 16

Sex
04-23-2011, 08:52 PM
Bitmap != png :o

Yago
04-23-2011, 09:20 PM
I saved it as a bmp on imageshack. The file it creates is empty and also a .bmp

Ill try another uploader see if it changes the extension

Edit: Anyone know of a website that doesn't change the image extensions?

Edit2: Got it to work by using a file hosting site... Thanks guys

Dgby714
04-23-2011, 09:53 PM
You can leave it as temp.bmp unless you add cache'in or somethin its only used right after its downloaded.

Sex
04-23-2011, 09:55 PM
You can leave it as temp.bmp unless you add cache'in or somethin its only used right after its downloaded.
Hey man, RewriteFile creates it if it doesn't exist.